SQLSTATE [01002] Adaptive Server连接失败(严重级9) [英] SQLSTATE[01002] Adaptive Server connection failed (severity 9)

查看:526
本文介绍了SQLSTATE [01002] Adaptive Server连接失败(严重级9)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下脚本来连接到我的Microsoft Azure服务器.

I have the following script to connect to my microsoft azure server.

<?php

try {
    $hostname = "secrets.database.windows.net";
    $dbname = "secrets";
    $username = "secrets";
    $pw = "secrets";
    $dbh = new PDO ("dblib:host=$hostname;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
}

echo "Passed!";

上面的脚本在我的旧服务器上传递,但是在新服务器上执行时会给我以下错误消息.

The script above passes on my old server, but gives me the following error message when executed from new server.

SQLSTATE[01002] Adaptive Server connection failed (severity 9)

我的新服务器PHP设置如下:

My new server PHP setup is as follows:

sudo apt-get install -y php5.6-fpm php5.6-ldap php5.6-curl php5.6-cli   php5.6-mcrypt php5.6-intl php5.6-json php5.6-pdo-dblib php5.6-mysqlnd php5.6-memcached php5.6-mbstring php5.6-imap php5.6-xml php5.6-sybase

到目前为止我的支票:

1)两者都有相同的面向公众的IP地址.

1) Both have same public facing IP address.

2)两者都具有相同的PHP PDO/ODBC设置.

2) Both have identical PHP PDO/ODBC setup.

$ php -i | grep PDO
DO
PDO support => enabled
PDO drivers => dblib, mysql, odbc
PDO Driver for FreeTDS/Sybase DB-lib => enabled
PDO Driver for MySQL => enabled
PDO_ODBC
PDO Driver for ODBC (unixODBC) => enabled

3)我可以使用以下命令从两个服务器使用telnet ping我的服务器:

3) I am able to ping my server using telnet from both servers using:

telnet secrets.database.windows.net 1433

任何建议将不胜感激.

推荐答案

进一步搜索之后,我遇到了这个答案.

After some further googling I came across this answer.

通过PDO ODBC将PHP连接到MSSQL

原来,我只需要更新/etc/freetds/freetds.conf

Turned out I just needed to update my /etc/freetds/freetds.conf

我的更改:

未注释的TDS协议版本并已更新.

Uncommented TDS protocol version and updated.

tds version = 8.0

在下面的示例中添加了mssql.

Added mssql below examples.

[mssql]
host =
Port = 1433
tds version = 8.0

这篇关于SQLSTATE [01002] Adaptive Server连接失败(严重级9)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆