SQL Server 2016安装在windows server 2012 R2 server "dev“上,sql server服务正在侦听端口1433上的所有IP。我可以使用sqlcmd从本地和另一个远程windows server 2012连接到它。命令很简单: sqlcmd -S dev\INSTACE -d -U test1 -P test1
然而,当我尝试从Ubuntu 16.04机器使用相同的命令进行连接时,我总是得到以下错误:
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2AF9.
Sqlcmd: Error: 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..
我还可以从Ubuntu服务器使用telnet连接端口1433。(telnet开发人员1433)。
感谢您的提示或帮助。
顺便说一下,我使用的不是freetds,而是适用于Ubuntu 16.04的OOTB Microsoft ODBC驱动程序。
还有一点:刚刚用jdbc测试过的SQL服务器可以使用jdbc从Ubuntu连接。
发布于 2017-04-23 22:15:53
最后,通过以下方法解决了这个问题: 1)在SQL server端的每个IP地址上启用TCP/IP。仅启用"IPAll“是不够的,还要启用每个TCP/IP地址,包括IPV4和IPV6。2)似乎你不能在命令中给出实例名称。在这种情况下,可以连接默认实例。除了默认实例之外,我还没有弄清楚如何处理实例名。3)在windows中,你不需要引号来包装密码,但在Ubuntu中你需要它。比如:"sqlcmd dev\MyInstance -U sa -P abcd!efg“可以在-S上运行,但不能在Ubuntu上运行。在Ubuntu中,我必须这样做:"sqlcmd -S dev -U sa -P 'abcd!efg‘
发布于 2018-06-01 08:05:44
正确的命令是:
sqlcmd -S dev\\\Instance,1433 -U test1 -P test1
根据设计,如果您使用命名实例,那么您需要提供端口号,即使它是默认端口,并且双反斜杠\\
也是必须的。参考:https://github.com/Microsoft/msphpsql/issues/442
https://stackoverflow.com/questions/43567256
复制相似问题