sql-server – freeTDS不使用其配置

前端之家收集整理的这篇文章主要介绍了sql-server – freeTDS不使用其配置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我决定使用FreeTDS驱动程序和unixODBC管理基于LAMP的应用程序与远程Mssql数据库之间的PDO连接。
不幸的是,驱动程序似乎没有读取freetds.conf文件,也没有直接通过服务器的CLI设置环境变量,或者通过putenv()函数PHP文件中指定环境变量。

现在一些数据:

>因为我ping服务器 – 没有数据包丢失。
>因为我在1433端口telnet服务器 – 连接建立
>我使用命令

TDSVER=7.0 tsql -H >IP< -p 1433 -U username

提示输入密码并建立连接。
>没有TDSVER之前的命令 – 连接失败与这样的消息:

Error 20017 (severity 9):
    Unexpected EOF from the server
    OS error 115,"Operation now in progress"
Error 20002 (severity 9):
    Adaptive Server connection Failed
There was a problem connecting to the server

> tsql -C命令回显这样的输出

Compile-time settings (established with the "configure" script)
                       Version: freetds v0.91
        freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: yes
   Sybase binary compatibility: no
                 Thread safety: yes
                 iconv library: yes
                   TDS version: 5.0
                         iODBC: no
                      unixodbc: yes
         SSPI "trusted" logins: no
                      Kerberos: no

> freetds.conf在上面给出的位置有这个条目:

[MSsql]
host = >IP<
port = 1433
tds version = 7.0

> Isql也失败:

isql -v MSsql
[S1000][unixODBC][FreeTDS][sql Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][sql Server]Adaptive Server connection Failed
[Isql]ERROR: Could not sqlConnect

>我的odbc.ini:

[MSsql]
Description = MS sql Server
Driver = FreeTDS
TDS_Version = 7.0
Server = >IP<
UID = username
PWD = password
ReadOnly = No
Port = 1433

我想这个解决方案真的很简单,但是我太笨了,找不到它

解决方法

我的直觉是你需要在你的freetds.conf和odbc.ini文件中将你的tds version = 7.0更改为tds version = 8.0,而你需要在你的odbcinst.ini文件里。这是我在Ubuntu 12.04服务器上与远程MSsql服务器通话的工作原理:

freetds.conf

# Define a connection to the MSsql server.
[mssql]
    host = myserver
    port = 1433
    tds version = 8.0

ODBC.INI

# Define a connection to the MSsql server.
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[mssql]
Description             = MSsql Server
Driver                  = freetds
Database                = MyDB
ServerName              = myserver
TDS_Version             = 8.0

ODBCINST.INI

# Define where to find the driver for the Free TDS connections.
[freetds]
Description     = MS sql database access with Free TDS
Driver          = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup           = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount      = 1

猜你在找的MsSQL相关文章