php远程连接sql server失败SQLSTATE] => 08001
mip版 关注:283 答案:2 悬赏:60
解决时间 2021-02-23 14:25
已解决
2021-02-23 02:28
我在本地测试远程连接服务器A的sql server没问题,但是我在服务器B上远程连接服务器A的sql server,出现此错误,跪求解决办法。
Array
(
[0] => Array
(
[0] => 08001
[SQLSTATE] => 08001
[1] => 1231
[code] => 1231
[2] => [Microsoft][SQL Server Native Client 10.0]Named
Pipes Provider: Could not open a connection to SQL Server [1231].
[message] => [Microsoft][SQL Server Native Client
10.0]Named Pipes Provider: Could not open a connection to SQL Server
[1231].
)
[1] => Array
(
[0] => HYT00
[SQLSTATE] => HYT00
[1] => 0
[code] => 0
[2] => [Microsoft][SQL Server Native Client 10.0]Login
timeout expired
[message] => [Microsoft][SQL Server Native Client
10.0]Login timeout expired
)
[2] => Array
(
[0] => 08001
[SQLSTATE] => 08001
[1] => 1231
[code] => 1231
[2] => [Microsoft][SQL Server Native Client 10.0]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.
[message] => [Microsoft][SQL Server Native Client 10.0]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.
)
)
最佳答案
2021-02-23 03:21
GRANT ALL PRIVILEGES ON 数据库.* TO 'root'@'localhost' IDENTIFIED BY '密码' with grant option;
GRANT ALL PRIVILEGES ON 数据库.* TO 'root'@'%' IDENTIFIED BY '密码'with grant option;
全部回答
1楼
2021-02-23 03:42
应该是你的sql server 2005 没有启用远程连接造成的,请参考以下方法启用远程连接
一、为 sql server 2005 启用远程连接
1. 单击"开始",依次选择"程序"、"microsoft sql server 2005"、"配置工具",然后单击"sql server 外围应用配置器"。
2. 在"sql server 外围应用配置器"页上,单击"服务和连接的外围应用配置器"。
3. 在"服务和连接的外围应用配置器"页上,展开"database engine"(数据库引擎),
单击"远程连接,选择"本地连接和远程连接"复选框,选择适用于您的环境的相应协议(我这里使用tcp/ip),然后单击"应用"。
注意:请在接收到以下消息时单击“确定”。
直到重新启动数据库引擎服务后,对连接设置所做的更改才会生效。
二、启用 sql server browser 服务
1. 单击"开始",依次选择"程序"、"microsoft sql server 2005"、"配置工具",然后单击"sql server 外围应用配置器"。
2. 在"sql server 外围应用配置器"页上,单击“服务和连接的外围应用配置器”。
3. 在"服务和连接的外围应用配置器"页上,单击"sql server browser",在"启动类型"中单击"自动"选项,然后单击"应用"。
4. 单击"启动",然后单击"确定"。
我要举报
如果感觉以上信息为低俗/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
点此我要举报以上信息!
推荐资讯
大家都在看