unixODBC + ODBC 驱动程序 13

unixODBC + ODBC Driver 13

我想使用以下 odbc.ini 连接到 MSSQL 数据库:

[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 的 vagrant 中,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 文件,我不知道如何找出问题所在。当我尝试从 vagrant ping 服务器时,一切正常。

我还在 windows 上尝试了 sqlcmd 工具,还在 vagrant 之外的 ubuntu 16.04 上尝试了 sqlcmd 工具。在 windows 上一切正常,但在 Ubuntu 上发生同样的错误。 命令:

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

您对如何跟踪或调试此问题有什么建议吗?

我在 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 也开始工作