今早开机发现,打开SQL Server 2008 的 SQL Server Management Studio,输入sa的密码发现,无法登陆数据库?提示以下错误:
“在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)“
在网上看到他人说使用将服务器(local)替换成本机的localhost,但是还是不行,后来自己重置了IP就可以了。具体如下:
1、打开Sql server 管理配置器

或者在命令行输入:SQLServerManager10.msc
2、点击MSSQLSERVER的协议,在右侧的页面中选择TCP/IP协议

3、右键点击TCP/IP协议,选择“属性”,需要修改连接数据库的端口地址

4、跳出来的对话框,里面有好多TCP/IP的端口,找到“IP3”,更改IP地址 为自己电脑的IP地址(或者是127.0.0.1) 在TCP端口添加1433,然后选择启动

5、“IPALL”的所有端口改成“1433”

6、重新启动服务


7、通过以上1-6步骤设置好端口,重新打开SQL Server Management Studio,在服务器名称输入:(local)或者127.0.0.1,即可登录数据库了。