雷达智富

首页 > 内容 > 程序笔记 > 正文

程序笔记

SQL Server2019无法通过IP登录和连接数据库

2024-06-14 35

使用基本类型安装了SQL Server2019数据库,并安装SSMS(SQL Server Management Studio)管理数据库。

在数据库所在的服务器上连接和登录数据库没有问题,但是在其他服务器上连接数据库会报错:

Exception: 

System.InvalidOperationException: The exception handler configured on ExceptionHandlerOptions produced a 404 status response. This InvalidOperationException containing the original exception was thrown since this is often due to a misconfigured ExceptionHandlingPath. If the exception handler is expected to return 404 status responses then set AllowStatusCode404Response to true.

 ---> Microsoft.Data.SqlClient.SqlException (0x80131904): 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)

 ---> System.ComponentModel.Win32Exception (5): 拒绝访问。

原因是通过基本类型方式安装后,SQL Server的TCP/IP协议没有启用。解决方法是:

打开SQL Server Configuration Manager,在SQL Server网络配置中启用TCP/IP协议。

找不到SQL Server Configuration Manager的话可以从开始菜单的Microsoft SQL Server 2019目录下找SQL Server 2019配置管理器。

启用TCP/IP协议,如下图所示:

启用后,重启SQL Server2019服务后,就可以通过IP登录和连接数据库了。

更新于:3个月前
赞一波!3

文章评论

全部评论