我决定使用FreeTDS驱动程序和unixODBC来管理基于LAMP的应用程序与远程MsSQL数据库之间的PDO连接。不幸的是,驱动程序似乎没有读取freetds.conf文件,也没有直接通过服务器的CLI设置或由putenv()函数在php文件中指定的环境变量。
现在一些数据:
TDSVER=7.0 tsql -H >IP< -p 1433 -U username
系统提示我输入密码并建立连接。
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
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
[MSSQL] host = >IP< port = 1433 tds version = 7.0
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
[MSSQL] Description = MS SQL Server Driver = FreeTDS TDS_Version = 7.0 Server = >IP< UID = username PWD = password ReadOnly = No Port = 1433
我想解决方案真的很简单,但是我太愚蠢了,找不到它…
我今天花了很长时间调试类似的问题。我在freetds.conf中设置了“ TDS版本”,但是在我的ODBC连接中没有使用它。阅读freetds源代码(connectparams.c:odbc_parse_connect_string)之后,我发现:
odbcinst.ini是一个红色鲱鱼。FreeTDS从不检查设置。
始终会遵守 在连接字符串 中指定的设置。它还始终尊重TDSVER之类的环境变量。