gpt4 book ai didi

sql-server - 从 Ubuntu 连接 SQL Server 时 sqlcmd 登录失败

转载 作者:行者123 更新时间:2023-12-04 18:54:28 28 4
gpt4 key购买 nike

SQL Server 2016 安装在 windows server 2012 R2 服务器“dev”上,并且 sql server 服务正在监听端口 1433 上的所有 IP。
我可以使用 sqlcmd 从本地和另一个远程 windows server 2012 连接到它。命令很简单:sqlcmd -S dev\INSTACE -d database -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 dev 1433)。

感谢提示或帮助。

顺便说一句,我没有使用 freetds,而是 OOTB Microsoft ODBC 驱动程序用于 Ubuntu 16.04。

再一:刚刚用jdbc测试过,可以使用jdbc从Ubuntu连接SQL server。

最佳答案

最后,这个问题通过以下方式解决:
1) 在 SQL 服务器端的每个 IP 地址上启用 TCP/IP。仅启用“IPAll”是不够的,而是启用每个 TCP/IP 地址,包括 IPV4 和 IPV6。
2)您似乎无法在命令中提供实例名称。在这种情况下可以连接默认实例。我还没有弄清楚如何处理默认实例以外的实例名称。
3) 在 Windows 中,您不需要引号来包装密码,但在 Ubuntu 中需要它。像:“sqlcmd -S dev\MyInstance -U sa -P abcd!efg”适用于 Windows,但不适用于 Ubuntu。在 Ubuntu 中,我必须这样做:“sqlcmd -S dev -U sa -P 'abcd!efg'

关于sql-server - 从 Ubuntu 连接 SQL Server 时 sqlcmd 登录失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43567256/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com