kha*_*vin 18 linux sql-server freetds ubuntu-10.04
我决定使用FreeTDS驱动程序和unixODBC来管理基于LAMP的应用程序与远程MsSQL数据库之间的PDO连接.不幸的是,驱动程序似乎没有读取freetds.conf文件,也没有直接通过服务器的CLI设置或通过putenv()函数在php文件中指定的环境变量.
现在一些数据:
因为我使用命令
TDSVER=7.0 tsql -H >IP< -p 1433 -U username
Run Code Online (Sandbox Code Playgroud)
系统提示我输入密码并建立连接.
没有命令前面的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
Run Code Online (Sandbox Code Playgroud)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
Run Code Online (Sandbox Code Playgroud)上面给出的位置的freetds.conf有这个条目:
[MSSQL]
host = >IP<
port = 1433
tds version = 7.0
Run Code Online (Sandbox Code Playgroud)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
Run Code Online (Sandbox Code Playgroud)我的odbc.ini:
[MSSQL]
Description = MS SQL Server
Driver = FreeTDS
TDS_Version = 7.0
Server = >IP<
UID = username
PWD = password
ReadOnly = No
Port = 1433
Run Code Online (Sandbox Code Playgroud)我想这个解决方案非常简单,但我发现它太愚蠢了......
Max*_*oke 26
我今天花了很长时间调试类似的问题.我在freetds.conf中设置了"TDS版本",但它没有在我的ODBC连接中使用.在阅读了freetds源代码(connectparams.c:odbc_parse_connect_string)后,我发现:
odbcinst.ini是一只红鲱鱼.FreeTDS从不检查设置.
始终遵守您在连接字符串中指定的设置.它也始终尊重TDSVER等环境变量.
Ben*_*ill 10
我的直觉是你需要在你的freetds.conf和odbc.ini文件中将tds version = 7.0更改为tds version = 8.0并且你需要在odbcinst.ini文件中使用某些东西.这是我在与远程MSSQL服务器通信的Ubuntu 12.04服务器上工作的内容:
freetds.conf
# Define a connection to the MSSQL server.
[mssql]
host = myserver
port = 1433
tds version = 8.0
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
小智 5
我遇到了完全相同的问题,但我的配置已经正确设置。问题是 freetds.conf 识别的 TDS 版本在新版本中发生了变化,但显然旧版本仍然在 TDSVER 环境变量中工作。一旦我将配置文件中的版本设置为 7.1 而不是 8.0,一切都开始工作了。
归档时间: |
|
查看次数: |
52156 次 |
最近记录: |