在RHEL 6上使用sqlcmd和odbc驱动程序连接到MSSQL服务器失败

我花了最后一个小时尝试通过odbc驱动程序使用sqlcmd连接到一个mssql服务器。 我正在跟db的家伙说话,但他似乎没有线索发生什么事情..也许你可以帮我找出一些问题,我可以问那个家伙..

我正在使用来自Microsoft的官方odbc驱动程序。 实际上,我们正在使用某种dynamic端口。

中间没有防火墙。

# odbcinst -q -d -n [PostgreSQL] [MySQL] [ODBC Driver 11 for SQL Server] 

我尝试了不同的方法

错误代码0x2AF9:

 sqlcmd -S hostname\DEV04 -U username -P password Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 11 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.. Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : TCP Provider: Error code 0x2AF9. 

查找服务器/实例指定的错误[xFFFFFFFF]。

 sqlcmd -S hostname\\DEV04 -U username -P password Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 11 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.. Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 

使用Perl

 DBI connect('DASHBOARD','username',...) failed: [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired (SQL-HYT00) [state was HYT00 now 08001] [unixODBC][Microsoft][ODBC Driver 11 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. (SQL-08001) [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. (SQL-08001) at ./test.pl line 4 Can't connect to : [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired (SQL-HYT00) [state was HYT00 now 08001] [unixODBC][Microsoft][ODBC Driver 11 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. (SQL-08001) [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. (SQL-08001) at ./test.pl line 4. 

我遇到了类似的问题。 事实certificate, hostname\DEV04\DEV04部分用于指示客户端应该连接到与默认端口不同的端口上的服务器。 在微软的世界里,使用DEV04自动确保客户端连接到正确的端口…但是这似乎不适用于Linux sqlcmd。

询问SQL Serverpipe理员\DEV04实例正在侦听哪个端口,并使用hostname,PORT连接