如何解决sql连接错误HResult 0x2, Level 16, State 1 Could not open a connection to SQL Server [2].

HResult 0x2, Level 16, State 1

Named Pipes Provider: Could not open a connection to SQL Server [2].

Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..

Error: Microsoft SQL Native Client : Login timeout expired.

在使用 sqlcmd试图连接本机数据库的时候出现以上错误,已经检查了以下情况:

1. sqlserver服务已开启

2. sqlserver browser已开启

3. TCP/IP 和 Named Pipes protocol 均开启

4. sql area configuration允许本地和远程连接

5. 防火墙1433端口准许连接

修改设置后已经重启sql服务,仍然得到以上错误

这个时候您需要检查服务端口设置了,默认端口均是0,你需要把默认端口改成可用的值(默认1433 和防火墙设置一致),保存后重启服务,问题解决。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值