为什么会出现“无法连接服务器-与网络有关或与实例有关的错误”?

本文翻译自:Why am I getting “Cannot Connect to Server - A network-related or instance-specific error”?

I get the following error when trying to connect to SQL Server: 尝试连接到SQL Server时出现以下错误:

Cannot connect to 108.163.224.173. 无法连接到108.163.224.173。

A network-related or instance-specific error occurred while establishing a connection to SQL Server. 建立与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. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。

(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326) (提供者:命名管道提供程序,错误:40-无法打开与SQL Server的连接)(Microsoft SQL Server,错误:1326)

This error is thrown when I try to configure my database to gridview in Visual Studio 2010. I'm at a loss as to how to debug this error. 当我尝试在Visual Studio 2010中尝试将数据库配置为gridview时,会引发此错误。我不知道如何调试此错误。

How would you debug this error? 您将如何调试此错误? What steps should I take in order to determine what is really going on here, in addition to the one mentioned in the error message? 除了错误消息中提到的步骤之外,我还应该采取什么步骤来确定实际发生的情况?


#1楼

参考:https://stackoom.com/question/1DmP5/为什么会出现-无法连接服务器-与网络有关或与实例有关的错误


#2楼

I found the following techniques helpful: 我发现以下技术很有帮助:

  1. Make sure your database engine is configured to accept remote connections : 确保您的数据库引擎配置为接受远程连接

    • Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration 开始>所有程序> SQL Server 2005>配置工具> SQL Server外围应用配置器
    • Click on Surface Area Configuration for Services and Connections 单击用于服务和连接的外围应用配置
    • Select the instance that is having a problem > Database Engine > Remote Connections 选择有问题的实例>数据库引擎>远程连接
    • Enable local and remote connections 启用本地和远程连接
    • Restart instance 重新启动实例
  2. You may need to create an exception on the firewall for the SQL Server instance and port you are using: 您可能需要在防火墙上为正在使用的SQL Server实例和端口创建一个例外

    • Start > Run > Firewall.cpl 开始>运行> Firewall.cpl
    • Click on exceptions tab 点击例外标签
    • Add sqlservr.exe (typically located in C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.x\\MSSQL\\Bin , check your installs for the actual folder path) and port (default is 1433 ) 添加sqlservr.exe(通常位于C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.x\\MSSQL\\Bin ,检查安装的实际文件夹路径)和端口(默认为1433
    • Check your connection string as well 还要检查您的连接字符串
  3. Check if your SQL server services is up and running properly: 检查您的SQL Server服务是否已启动并正常运行:

    • Go to All Programs > Microsoft SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services 转到所有程序> Microsoft SQL Server 2008>配置工具> SQL Server配置管理器> SQL Server服务
    • Check to make sure SQL Server service status is Running. 检查以确保SQL Server服务状态为“正在运行”。

    In addition, ensure that your remote server is in the same network . 此外,请确保您的远程服务器在同一网络中 Run sqlcmd -L to ascertain if your server is included in your network list. 运行sqlcmd -L以确定您的服务器是否包含在网络列表中。

  4. Enable TCP/IP in SQL Server Configuration 在SQL Server配置中启用TCP / IP

    When two or more SQL Servers are connected across network they do all communication using TCP/IP. 当通过网络连接两个或多个SQL Server时,它们将使用TCP / IP进行所有通信。 The default port of SQL Server installation is 1433. This port can be changed through SQL Server Configuration Manager. SQL Server安装的默认端口为1433。可以通过SQL Server配置管理器更改此端口。 TCP/IP should be enabled for SQL Server to be connected. 应该为要连接的SQL Server启用TCP / IP。

    • Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP 转到所有程序>> Microsoft SQL Server 2008 >>配置工具>> SQL Server配置管理器>>选择TCP / IP
    • Right Click on TCP/IP >> Click on Enable 右键单击TCP / IP >>单击启用

    You must restart SQL Server Services for all the changes to take effect. 您必须重新启动SQL Server服务,所有更改才能生效。 Right click and go to menu properties to select location where default port of SQL Server can be changed. 右键单击并转到菜单属性,以选择可以更改SQL Server默认端口的位置。


#3楼

I got Solution for me : 我为我找到了解决方案:

Open "SQL Server Configuration Manager" 打开“ SQL Server配置管理器”

Now Click on "SQL Server Network Configuration" and Click on "Protocols for Name " 现在,单击“ SQL Server网络配置”,然后单击“ 名称协议”

Right Click on "TCP/IP" (make sure it is Enabled) Click on Properties 右键单击“ TCP / IP”(确保已启用),单击“属性”。

Now Select "IP Addresses" Tab -and- Go to the last entry "IP All" 现在,选择“ IP地址”选项卡-并且-转到最后一个条目“ IP全部”

Enter "TCP Port" 1433. 输入“ TCP端口” 1433。

Now Restart "SQL Server .Name." 现在, 重新启动 “ SQL Server .Name”。 using "services.msc" (winKey + r) 使用“ services.msc”(winKey + r)

It Will Work... 它会工作...


#4楼

如果以上解决方案都不起作用(对我而言没有任何帮助),则只需重新启动计算机,您就可以连接到sql服务器(本地主机)。


#5楼

I have to run SQL Server Browser service into SQL Server Configuration Manager . 我必须将SQL Server浏览器服务运行到SQL Server配置管理器中 Installation can't discover newly created service without this. 没有此安装程序将无法发现新创建的服务。


#6楼

I am solving that problem by opening Services then start running Sql Server (Sqlexpress) service. 我通过打开“ 服务”来解决该问题,然后开始运行Sql Server(Sqlexpress)服务。

服务形象

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值