2017-07-18 92 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开始工作