【问题标题】:PDOException: SQLSTATE 01002 Adaptive Server connection failed (severity 9)PDOException: SQLSTATE 01002 Adaptive Server 连接失败(严重性 9)
【发布时间】:2017-02-15 14:22:05
【问题描述】:

我一直在关注stackoverflow的一些答案。

我的 odbc。 ini(位于/etc/odbc.ini)

[MSSQL]
Description = MS SQL Server
Driver = /usr/local/lib/libtdsodbc.so
Server = host.of.the.server
UID = myusername
PWD = mypassword
ReadOnly = No
Port = 1433
tds version = 8.0

我的 odbcinst.ini

[FreeTDS]
Description = FreeTDS driver
Driver = /usr/local/lib/libtdsodbc.so
Setup=/usr/lib/odbc/libtdsS.so
FileUsage = 1
UsageCount = 1

这两个文件一开始都是空的。我只是从其他线程中复制了答案。

我的 freetds.conf

# Global settings are overridden by those in a database
# server specific section
[global]
        # TDS protocol version
;       tds version = 8.0

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
;       dump file = /tmp/freetds.log
;       debug flags = 0xffff

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10

        # If you get out-of-memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.
        # Try setting 'text size' to a more reasonable limit
        text size = 64512

# A typical Sybase server
[egServer50]
        host = symachine.domain.com
        port = 5000
        tds version = 8.0

# A typical Microsoft server
[egServer70]
        host = ntmachine.domain.com
        port = 1433
        tds version = 7.0

我正在使用 Laravel。现在,在我使用了

php artisan migrate 

我收到以下错误:PDOException: SQLSTATE 01002 Adaptive Server 连接失败(严重性 9)

stackoverflow 的一些答案:可能的原因是 TDS 版本。

所以我用tsql -C

    Version: freetds v0.91
         freetds.conf directory: /usr/local/etc
 MS db-lib source compatibility: yes
    Sybase binary compatibility: no
                  Thread safety: yes
                  iconv library: yes
                    TDS version: 5.0
                          iODBC: no
                       unixodbc: yes
          SSPI "trusted" logins: no
                       Kerberos: no

我正在使用 Ubuntu 16

【问题讨论】:

标签: php laravel freetds sqlsrv unixodbc


【解决方案1】:

尝试将 TDS 版本更改为 7.0 或 8.0 并确保您已安装以下软件包 -

php5-sybase 
php5-odbc 

【讨论】:

  • 如何更改我的 TDS 版本。我已经编辑了所有的 .ini 文件。
  • 您的 freetds.conf 文件显示版本为 8.0,但是当您运行 tsql -C 时,TDS 版本显示为 5.0 您确定 tds 引用了正确的 freetds.conf 文件吗?这个链接是我的帮助 - freetds.org/userguide/freetdsconf.htm
  • 另外,为了面向未来,您需要使用 TDS 版本 7.1,不是 8.0。永远不要使用 8.0,它是一个已弃用的值,将从 FreeTDS 中删除。
  • 好建议。我不知道 8.0 正在贬值。
猜你喜欢
  • 2016-09-09
  • 2014-09-13
  • 2017-01-09
  • 2013-12-10
  • 2019-11-20
  • 2015-10-27
  • 2019-08-19
  • 2022-12-24
  • 2016-07-13
相关资源
最近更新 更多