我目前正在设置从Linux机箱到Microsoft sql服务器的连接.我在Linux机器上安装了FreeTDS和pyodbc.
我已经设置了以下文件:
/etc/freetds/freetds.conf
[sqlserver]
host =
〜/ .odbc.ini的
[sqlserver]
Description = FreeTDS MSsql
Driver = FreeTDS
Servername =
/etc/odbcinst.ini
[FreeTDS]
Description = FreeTDS MSsql
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Driver64 = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount = 1
CPTimeout =
CPTimeToLive =
DisableGetFunctions =
DontDLCLose =
ExFetchMapping =
Threading =
FakeUnicode =
IconvEncoding =
Trace =
TraceFile =
TraceLibrary =
当我尝试运行tsql -S sqlserver -U username -P密码时,出现以下错误:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 18452 (severity 14,state 1) from SYMPLECTIC03 Line 1:
"Login Failed. The login is from an untrusted domain and cannot be used with Windows authentication."
Error 20002 (severity 9):
Adaptive Server connection Failed
There was a problem connecting to the server
我也尝试用pyodbc连接,在下面的脚本中:
import pyodbc
try:
cnxn = pyodbc.connect('DRIVER=FreeTDS;SERVER=same_ip_as_above;DATABASE=Reports;UID=myusername;PWD=mypassword')
except pyodbc.Error,err:
print err
这会打印以下错误:
('001','[001] [nxDC[reD]SLSre]nbet onc odt ore (0) (sqlDriverConnect)')
不完全是最有用的错误消息.
尝试连接时有什么问题吗?
作为旁注,我们的数据库需要Windows身份验证,而不是集成.
我可以telnet连接到主机,所以这也不是问题.
最佳答案
安装看起来很好.我有一个类似的工作,在服务器升级到NTLMv2后中断了.这在测试tsql时出现了“…不受信任的域……”错误. * detail here
我只需要在我的freetds.conf规范中包含使用ntlmv2 = yes.