且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP sqlsrv_connect to SQL Server:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误

更新时间:2023-02-03 08:02:40

当 MS SQL Server 实例设置不正确时,我收到此错误.

I get this error when MS SQL Server instance is not set correctly.

可能的解决方案:

您应该检查您的服务器网络配置.转到 SQL Server 配置管理器(或计算机管理\服务和应用程序\SQL Server 配置管理器),然后转到 SQL Server 网络配置,InstanceName"的协议.首先,必须启用 TCP/IP.然后打开 TCP\IP 的属性.在IP 地址"选项卡上,转到 IPAll.要使此脚本工作,TCP 动态端口"必须为空,并且TCP 端口"必须等于 1433(或其他端口).

You should check your server network configuration. Go to SQL Server Configuration Manager (or Computer Management\Services and Applications\SQL Server Configuration Manager), then go to SQL Server Network Configuration, Protocols for "InstanceName". First, TCP/IP must be enabled. Then open Properties for TCP\IP. On "IP Addresses" tab, go to IPAll. For this script to work "TCP Dynamic ports" must be empty, and "TCP Port" must equals to 1433 (or some other port).

注意:

如果SQL Server Browser 服务"正在运行,则无需端口号即可连接.

If "SQL Server Browser service" is running, you can connect without port number.