无法使用PHP sqlsrv_connect连接 - 找不到服务器

时间:2017-02-28 15:52:42

标签: php sql-server

我正在使用PHP 7.0.15,在本地运行IIS,而我正在尝试连接到我们的主SQL Server框。我已经成功加载了sqlsrv扩展,用

进行了测试
echo "Did sqlsrv load? " . (extension_loaded('sqlsrv') ? "YES" : "NO");

返回YES。我正在连接的盒子上的SQL实例是hdnysql1 \ hdnysql1,用select @@ serverName验证。我已经检查过我可以使用Windows身份验证连接运行SQL Server Management Studio,我正在尝试在代码中使用Windows身份验证:

$servername = "hdnysql1\hdnysql1";
$connectionInfo = array("Database"=>"MCDB_Test");
$conn = sqlsrv_connect($serverName, $connectionInfo);

这会返回连接失败; sqlsrv_errors返回一个包含

的数组
Named Pipes Provider: Could not open a connection to SQL Server
Login timeout expired
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.

我按照说明here验证了允许远程连接到服务器。 SQL Server配置管理器中的TCP端口设置为空;我在IP2上设置为1433,重新启动服务,事情似乎正在发挥作用; SSRS也必须重新启动,但是工作正常。我通过端口1433 telnet到服务器以确保它已打开并禁用我的防火墙,但仍然没有运气 - 仍然收到相同的消息。任何帮助将不胜感激。

0 个答案:

没有答案
相关问题