2017-07-18 245 views
1

我想與下面的odbc.ini連接MSSQL數據庫:的unixODBC + ODBC驅動程序13

[ODBC Driver 13 for SQL Server] 
Description=Microsoft ODBC Driver 13 for SQL Server 
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.0 
Trace=yes 
TraceFile=/db.log 
User=[user] 
Password=[password] 
Server=[server]\[instance] 
Database=[db_name] 
UsageCount=5 

我能夠從PyCharm連接到數據庫,所以證書應該罰款。一切都裝在流浪者與Debian的8和unixODBC的版本是2.3.1。 錯誤消息如下:

[HYT00][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired 
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF]. 
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. 
[ISQL]ERROR: Could not SQLConnect 

我沒有db.log文件,我不知道該怎麼想通了其中的問題。當我嘗試ping服務器從流浪者一切工作正常。

我也嘗試sqlcmd工具在窗戶和ubuntu 16.04以外的流浪漢。在Windows上一切正常,但在Ubuntu相同的錯誤發生。 命令:

sqlcmd -S [server]\[instance] -U [user] -d [table_name] -P [password] 

你有一些建議,如何跟蹤或調試這個問題?

回答

0

我找到了答案DBA。 所以在Linux上不工作的命令:

sqlcmd -S [server]\[instance] -U [user] -d [table_name] -P [password] 

只是

sqlcmd -S [server],[port] -U [user] -d [table_name] -P [password] 

而且你需要以某種方式找到此端口。在此之後Pyodbc開始工作