我目前正在設置從Linux機器到Microsoft SQL服務器的連接。我在Linux上安裝了FreeTDS和pyodbc。freetds和pyodbc無法連接
我已經建立了以下文件: /etc/freetds/freetds.conf
[sqlserver]
host = <ip address>
port = 1433
tds version = 8.0
client charset = UTF-8
〜/ .odbc.ini的
[sqlserver]
Description = FreeTDS MSSQL
Driver = FreeTDS
Servername = <same ip as above>
Database = Reports
TDS_Version = 8.0
/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用戶名-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)')
不完全是最有幫助的錯誤消息。
嘗試連接時有什麼我做錯了嗎?
請注意,我們的db需要Windows身份驗證,而不是集成的。 我可以telnet連接到主機,所以這也不是問題。