【问题标题】:Freetds could not connect to SQL Azure by server name (-S), but connect by host (-H) worksFreetds 无法通过服务器名称 (-S) 连接到 SQL Azure,但通过主机连接 (-H) 有效
【发布时间】:2016-09-06 20:19:13
【问题描述】:

我已经安装了 freetds,当我尝试通过主机连接时,它看起来工作正常:

tsql -H myhost -U myuser -P mypass -p 1433
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
1> 

我已经配置了freetds.conf:

[azure]
        host = myhost
        port = 1433
        tds version = 7.0

但是当我尝试通过服务器名称(天蓝色)连接时,它会失败:

tsql -S azure -U myuser -P mypass
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 40532 (severity 20, state 1) from azure:
    "Cannot open server "azure" requested by the login.  The login failed."
Error 20002 (severity 9):
    Adaptive Server connection failed

在 macos 和 debian 上试过。

【问题讨论】:

    标签: sql-server azure azure-sql-database freetds


    【解决方案1】:

    答案很简单,但很奇怪。当您通过配置文件 (-S) 连接时,您应该使用 username@host 作为登录名,而不仅仅是用户名。这很奇怪,但是当您通过主机(-H)连接时,您只能使用用户名(但也可以使用用户名@主机)。

    【讨论】:

    • 哇。这是完美的。我花了几个小时才达到这一点。谢谢!
    【解决方案2】:

    很高兴它对你有用。查看此文档 - http://www.freetds.org/userguide/odbcconnattr.htm

    作为一般惯例,我们建议您使用 -S

    如果您还有其他问题,请告诉我。

    【讨论】:

    • 链接看起来死了
    猜你喜欢
    • 2021-01-19
    • 1970-01-01
    • 2020-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    相关资源
    最近更新 更多