且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与 SQL Server 建立连接时发生与网络相关或特定于实例的错误

更新时间:2023-02-03 08:02:22

当您的应用程序没有足够的权限访问数据库时,Sql Server 会触发此错误.这个错误有几个原因.要修复此错误,您应该遵循以下说明.

Sql Server fire this error when your application don't have enough rights to access the database. there are several reason about this error . To fix this error you should follow the following instruction.

  1. 尝试使用 management studio 从您的服务器连接 sql server.如果您使用 Windows 身份验证连接 sql server,则将您的应用程序池标识设置为服务器管理员.

  1. Try to connect sql server from your server using management studio . if you use windows authentication to connect sql server then set your application pool identity to server administrator .

如果您使用 sql server 身份验证,请检查您的 web 应用程序的 web.config 中的连接字符串,并设置允许您登录的 sql server 的用户 ID 和密码.

if you use sql server authentication then check you connection string in web.config of your web application and set user id and password of sql server which allows you to log in .

如果您的数据库在其他服务器上(访问远程数据库),那么首先从 sql server management studio 启用远程访问 sql server 表单 sql server 属性,并启用 TCP/IP 表单 sql server 配置管理器.

if your database in other server(access remote database) then first of enable remote access of sql server form sql server property from sql server management studio and enable TCP/IP form sql server configuration manager .

在做完所有这些事情后,您仍然无法访问数据库,然后检查您尝试访问数据库的服务器表单的防火墙,并在防火墙中添加一个规则以启用 sql server 的端口(默认为 sqlserver 使用 1433 ,要检查 sql server 的端口,您需要检查 sql server 配置管理器网络协议 TCP/IP 端口).

after doing all these stuff and you still can't access the database then check firewall of server form where you are trying to access the database and add one rule in firewall to enable port of sql server(by default sql server use 1433 , to check port of sql server you need to check sql server configuration manager network protocol TCP/IP port).

如果您的 sql server 在命名实例上运行,那么您需要使用 sql serer 名称写入端口号,例如 117.312.21.21/nameofsqlserver,1433.

if your sql server is running on named instance then you need to write port number with sql serer name for example 117.312.21.21/nameofsqlserver,1433.

如果您使用像 amazon aws 或 microsoft azure 这样的云托管,那么服务器或实例将在云防火墙后面运行,因此如果您有默认实例或 sql server 的特定端口,则您需要在云防火墙中启用 1433 端口实例.

If you are using cloud hosting like amazon aws or microsoft azure then server or instance will running behind cloud firewall so you need to enable 1433 port in cloud firewall if you have default instance or specific port for sql server for named instance.

如果您使用的是 amazon RDS 或 SQL azure,那么您需要从该实例的安全组启用端口.

If you are using amazon RDS or SQL azure then you need to enable port from security group of that instance.

如果您通过 sql server 身份验证模式访问 sql server,请确保您启用了SQL Server 和 Windows 身份验证模式"sql server 实例属性.

If you are accessing sql server through sql server authentication mode them make sure you enabled "SQL Server and Windows Authentication Mode" sql server instance property.

  1. 在对属性进行任何更改后重新启动 sql server 实例,因为某些更改需要重新启动.

如果您进一步遇到任何困难,那么您需要提供有关您的网站和 sql server 的更多信息.

if you further face any difficulty then you need to provide more information about your web site and sql server .