Loading... # 引言 当前项目使用的是SQLServer,为了方便本机调试,将数据库安装到本地,但是连接时出现了问题,报错如下。 ```bash A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ``` # 解决方案 1. 设置登录的账号和密码 ![image.png](https://www.zunmx.top/usr/uploads/2021/07/3233885124.png) ![image.png](https://www.zunmx.top/usr/uploads/2021/07/2452096492.png) 2. 开启账号密码形式验证的方式和远程登录 ![image.png](https://www.zunmx.top/usr/uploads/2021/07/2448993842.png) ![image.png](https://www.zunmx.top/usr/uploads/2021/07/1444275245.png) ![image.png](https://www.zunmx.top/usr/uploads/2021/07/525867346.png) 3. 启动TCP/IP协议,打开配置管理器 ![image.png](https://www.zunmx.top/usr/uploads/2021/07/1340294642.png) ![image.png](https://www.zunmx.top/usr/uploads/2021/07/965533772.png) 4. 重启SQLServer服务 ![image.png](https://www.zunmx.top/usr/uploads/2021/07/1931791062.png) 5. 测试 通过Navicat测试链接MSSQL成功,项目中也可以正常连接数据库了 ![image.png](https://www.zunmx.top/usr/uploads/2021/07/3422366531.png) © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏