当我尝试连接SQL Server时,我得到以下错误:

在建立与SQL Server的连接时,发生了与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。验证实例名称是否正确,SQL Server是否配置为允许远程连接。(提供商:Named Pipes提供商,错误:40 -无法打开到SQL Server的连接)

当我试图在Visual Studio 2010中将数据库配置为gridview时抛出此错误。我不知道如何调试这个错误。

如何调试此错误?除了错误消息中提到的步骤之外,我还应该采取哪些步骤来确定这里到底发生了什么?


我发现以下技巧很有用:

Make sure your database engine is configured to accept remote connections: Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration 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 You may need to create an exception on the firewall for the SQL Server instance and port you are using: Start > Run > 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) Check your connection string as well From FIX : ERROR : Could not open a connection to SQL Server: Check if your SQL server services is up and running properly: Go to All Programs > Microsoft SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services Check to make sure SQL Server service status is Running. 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. Enable TCP/IP in SQL Server Configuration When two or more SQL Servers are connected across network they do all communication using TCP/IP. The default port of SQL Server installation is 1433. This port can be changed through SQL Server Configuration Manager. TCP/IP should be enabled for SQL Server to be connected. Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP Right Click on TCP/IP >> Click on Enable You must restart SQL Server Services for all the changes to take effect. Right click and go to menu properties to select location where default port of SQL Server can be changed.

我有自己的解决方案:

打开“SQL Server配置管理器” 现在点击“SQL Server网络配置”,然后点击“协议名称” 右键单击“TCP/IP”(确保它是启用的)单击属性 现在选择“IP地址”选项卡-转到最后一个条目“IP所有” 输入“TCP端口”1433。 现在重新启动“SQL Server . name .”使用“服务”。(winKey + r)

它会起作用……

如果以上解决方案都不起作用(对我来说都不起作用),那么只需重新启动计算机,您就可以连接到sql server (localhost)。

我必须运行SQL Server浏览器服务到SQL Server配置管理器。 如果没有这个,安装就不能发现新创建的服务。

我通过打开服务来解决这个问题,然后开始运行Sql Server (Sqlexpress)服务。

当我想在另一台PC上运行我的WinForms项目(包括使用SQL Server数据库,并且在我的PC上工作得很好)时,我也犯了同样的错误。问题出在我电脑的Windows防火墙上。我通过添加两条规则来解决这个问题。这是如何允许SQL Server通过Windows防火墙的整个过程:

打开“运行”,输入services.msc 查找用于SQL Server(实例名)和SQL Server Browser的服务。一次一个,右键单击,选择“属性”,复制路径到exe文件 然后打开防火墙。cpl,单击允许应用程序或添加规则,添加之前复制的路径(有一个步骤需要遵循),选中域和私有,取消选中公共。

这是YouTube的链接,你可以看到这个过程:允许SQL Server通过Windows防火墙

在做了上面提到的所有事情之后: http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/ 对我来说还是没用。

以下步骤对我很有效:

开始>执行> cmd > sqlcmd -L

它将提示您服务器名。确保此服务器名称与SQL management studio的CONNECT to server框中试图连接的服务器名称相同。

我犯了这个愚蠢的错误,我一直使用MSSQLSERVER而不是使用这个服务器名。

希望这对像我一样犯愚蠢错误的人有所帮助。

谢谢。

按window + R(运行窗口打开),在运行窗口类型“服务”。msc”和新服务打开找到实例名SQL SERVER在我的情况下,它是SQL SERVER(SQLEXPRESS),然后启动这个服务,再试一次,它为我工作,希望它也为你工作。

当sql server实例停止时发生此错误。

进入所有程序>SQL Server >配置工具>SQL Server配置管理器

然后点击SQL sERVER SERVICES,实例列表将出现,选择实例问题,并点击顶部工具栏上的播放图标,希望这将有所帮助。

这个答案很晚(但晚总比不到好;)

虽然以上的解决方案应该在90%的情况下工作,但如果你还在阅读这个答案!!您可能正在尝试连接到与预期不同的服务器。这可能是由于配置文件指向不同的SQL服务器,而不是您认为要连接的实际服务器。

至少在我身上发生过。

我尝试了关于这个问题的所有其他答案,其中一些(如果不是全部的话)可能在让这个为我工作方面发挥了作用,但我仍然无法远程连接到DB。我在Azure虚拟机上使用SQL Server。

我最终想起了VM的端点是由Azure帐户代理控制的,所以我继续使用Azure Portal并添加1433作为可用端点,这样我就可以连接到我的SQL实例了。

希望这能帮助那些尝试了所有其他答案但仍然没有运气的人!

把我的高度好评的评论作为一个截图的回答。

我在这上面花了很多时间,最后对我有用的是:

1)打开Sql Server Configuration Manager—> Sql Server Network Configuration—> Protocols for <(INSTANCE)>—> TCP/IP(双击它)。

2)选择“——> IP Addresses(Tab)”。

3)转到最后一个条目IP All,并提到TCP端口1433。

4)按“Win+R”,输入services.msc。

5)现在重启SQL Server <(INSTANCE)>。

在这之后,问题解决了!

如果你使用的是快速版:

您需要在服务器名称后添加\SQLEXPRESS

例如我的服务器\ SQLEXPRESS

我遇到了同样的问题,问题是我在解决方案(Weband Droid)中有几个项目,即使在包管理器控制台中选择了默认项目,它也使用了Droid项目的连接字符串:

PM> update-database -Verbose
Using StartUp project 'Droid'. <-- DROID
Using NuGet project 'Web'. <-- WEB
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
<!-- BAD TARGET DATABASE -->
Target database is: 'DefaultConnection' (DataSource: .\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Convention).
System.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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
   [REMOVED TEXT]
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-1,State:0,Class:20
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

在包管理器控制台设置启动项目到Web和默认项目后,我得到了它的工作。

我将使用Entity Framework的项目设置为启动项目,然后运行update-database命令,解决了这个问题。

我使用的是SQL Server 2016和windows 10。

首先是允许远程连接到SQL Server。 我所做的就是键入sqlservermanager13。在开始菜单打开SQL Server配置管理器。确保TCP/IP状态为启用状态。

双击TCP/IP协议名称,检查TCP端口号。通常默认值是1433。

以下步骤通过使用Microsoft管理控制台(MMC)管理单元配置Windows防火墙的高级安全。高级安全Windows防火墙只配置当前配置文件。

To open a port in the Windows firewall for TCP access On the Start menu, click Run, type WF.msc, and then click OK. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane. In the Rule Type dialog box, select Port, and then click Next. In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the Database Engine, such as 1433 for the default instance. Click Next. In the Action dialog box, select Allow the connection, and then click Next. In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next. In the Name dialog box, type a name and description for this rule, and then click Finish.

另一个需要配置的东西。

To open access to SQL Server when using dynamic ports On the Start menu, click Run, type WF.msc, and then click OK. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane. In the Rule Type dialog box, select Program, and then click Next. In the Program dialog box, select This program path. Click Browse, and navigate to the instance of SQL Server that you want to access through the firewall, and then click Open. By default, SQL Server is at C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\Sqlservr.exe. Click Next. In the Action dialog box, select Allow the connection, and then click Next. In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next. In the Name dialog box, type a name and description for this rule, and then click Finish.

看看微软的文档 配置Windows防火墙访问数据库引擎

如果在Visual Studio中调试时遇到这种情况,请确保项目构建路径指向本地驱动器,或者按照以下步骤为网络文件夹授予权限。

我把安装Windows 7的工作笔记本电脑换成了安装Windows 10的工作笔记本电脑。 我已经在Windows 7上成功使用了SSMS2016。

使用SSMS2012或SSMS2016时也出现了同样的问题。 我使用windows身份验证访问10个SQL服务器的权限仍然相同。我可以在另一个服务器上测试。 但是,10个服务器中的2个无法从我的笔记本电脑连接。 两者都是ms SQL server 9,但我可以连接到另一个SQL server 9数据库。

解决方案是添加防火墙规则(使用带高级安全的Windows防火墙)。

为每个SSMS创建一个Incoming规则 例如C:\Program Files (x86)\Microsoft SQL Server\130\Tools\ bin \ManagementStudio\ sssm .exe

我不是网络专家,所以我没有包括细节,但希望它能给你指明正确的方向。


错误信息msg (pre防火墙规则) "在建立与SQL Server的连接时,发生了与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。验证实例名称是否正确,SQL Server是否配置为允许远程连接。(提供者:SQL网络接口,错误:26 -错误定位指定的服务器/实例)(。Net SqlClient数据提供程序

似乎您的localdb实例没有运行。 要在计算机启动时启动它,添加到您的开始菜单\启动文件夹BAT文件与以下行

sqllocaldb start name_of_instance

其中name_of_instance是要启动的localdb实例的名称。 您可以使用sqllocaldb i在命令行中列出可用的实例。

例如,如果您正在使用SQL Server Management Studio并连接到服务器名称(localdb)\v11.0,那么您的BAT文件将如下所示

sqllocaldb start v11.0

我的问题开始于我试图将服务器从IIS Express更改为本地IIS(同时使用LocalDB)。

我正在使用LocalDB(用于开发目的),当我从本地IIS恢复到IIS Express时,Visual Studio已经将我的数据源从数据源=(LocalDB)\MSSQLLocalDB切换到数据源=.\SQLEXPRESS

错误的连接字符串

< add name = " DefaultConnection connectionString =“源代码=数据。\ SQLEXPRESS; AttachDbFilename = | DataDirectory | \ SurveyTestsDB。中密度纤维板;最初用户目录= SurveyTestsDB集成安全= True;例如= True” providerName =“系统数据。SqlClient " - >

正确的连接串

< add name = " DefaultConnection connectionString =“源代码=数据(LocalDb) \ MSSQLLocalDB; AttachDbFilename = | DataDirectory | \ SurveyTestsDB。中密度纤维板最初目录》中= SurveyTestsDB;集成安全= True”providerName =“系统数据。SqlClient " - >

希望这能帮助到一些人。

我的问题是,你需要在存储库层和web层都有一个连接字符串条目。有一次我把它加到我的网里。config以及我的app.config,实体框架能够创建迁移。

我的问题是,为什么网络。配置需要它,当绝对没有数据库访问那里。

这个解决方案解决了SQL服务器背后的网络错误和服务问题

我在这里回答了一个类似的问题,您需要统计其他开放运行类型->服务。msc -在服务->排序停止你会看到一堆停止的SQL服务右键单击并启动

开始-有4个问题可能会导致常见的LocalDb SqlExpress Sql Server连接错误Sql网络接口,错误:50 -本地数据库运行时错误发生,在开始之前,您需要将v11或v12重命名为(LocalDb)\mssqllocaldb


Troubleshooting Steps

您没有正在运行的服务,执行命令net start MSSQLSERVER或net start MSSQL$ instancename 这里没有防火墙端口 配置 你的安装有问题/损坏(下面的步骤可以帮助你一个干净的开始) 您没有将V11或12重命名为mssqllocaldb/SqlServer

我发现最简单的是做下面的事情——我附上了图片和步骤以寻求帮助。


Resolution Steps:

首先验证您已经安装了哪个实例,您可以通过检查注册表并运行cmd来完成此操作

i .执行命令> Sqllocaldb.exe cmd> Sqllocaldb.exe s "那个versionyouwantfromlistbefore " 如果此步骤失败,可以使用选项d删除cmd> Sqllocaldb.exe d "someDb" cmd> Sqllocaldb.exe c "createSomeNewDbIfyouWantDb" cmd> Sqllocaldb.exe start "createSomeNewDbIfyouWantDb"


重新启动MSSql服务器或简单地重新启动您的机器!

按住/按打开CMD,窗口+ R,输入“services.msc” 现在寻找sql server服务,打开查找带有实例名的sql server 然后重新启动此服务并重试

除了尝试Teo Chuen Wei Bryan建议的所有方法外,还要确保在连接字符串中引用了正确的服务器/实例名称。

如果您在数据库服务器或web上使用主机名/实例的简写形式。配置文件,确保您使用完全限定域名(FQDN)/实例

此外,要从不存在SQL server客户端的服务器测试连通性,

——>创建一个文本文件,并将其扩展名为。udl

右键单击文件,你可以看到连接选项卡。

——>输入服务器名和登录信息,测试连接到数据库服务器。

希望这能有所帮助。

您可以测试以下方法。

a Check the connection string of the project. b Go to services and restart SQLServer Instance. c Open 'SQLServer Configuration Manager' In the left panel select 'SQLServer Network Configuration' and expanding it Select 'Protocols for MSSQLServer' In the right panel dbl click on 'TCP/IP' In the 'Protocol' tab set the 'Enabled' to 'Yes' In the 'IP Addresses' tab scroll to down In the 'IPAll' set 'TCP Port' to 1433 d Open 'Firewall with advanced security' In the right tab select 'Inbound Rules'

在中间选项卡找到“本地端口”是1433的记录,如果你找不到它,尝试用以下级别创建它

In the Start menu, click Run, type 'WF.msc', and then click OK In the left panel click the 'Windows Firewall with Advanced Security' In the right panel right-click 'Inbound Rules', and then click 'New Rule' In the Rule Type dialog box, select 'Port', and then click Next In the Protocol and Ports dialog box, select 'TCP', and select 'Specific Local Ports', and then type the port number 1433, Click Next In the Action dialog box, select Allow the connection, and then click Next In the 'Profile' dialog box, checking the Domain, Private and Public, Then click Next In the 'Name' dialog box, type 'SQL 1433 Port' and for a description write description for own. Then click Finish

Then in the middle tab double click the found item(Instance) or created item of 'SQL 1433 Port' name by you. Select 'Scope' tab in opened dialog box(SQL Server Properties) In the Local PC Go to google.com in your Browser and search 'My IP'. then copy of your 'IP' Go to the remote server and in the 'SQL Server Properties' dialog box of 'Scope' tab, in the 'Remote IP Address' select the 'These IP Addresses' option and click 'Add' button In the opened dialog box(IP Address) select 'This IP Address or Subnet' option and paste your 'IP', click OK button.

如果您突然在生产环境中遇到这个错误,并且没有任何更改,请尝试以下顺序中的4个项目,以查看它是否得到修复。

重新启动SQL server服务。 重新启动调用sql server的服务(比如IIS)。(如果从开始对SQL server的服务调用到最终得到响应错误的时间非常短(大约一到两秒),那么问题可能就在这里。 重新启动服务器SQL server is on。 重新启动调用服务所在的服务器。

当我在Visual Studio中遇到这个错误时,

"在建立与SQL Server的连接时,发生了与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。验证实例名称是否正确,SQL Server是否配置为允许远程连接。(提供商:命名管道提供商,错误:40 -无法打开到SQL Server的连接)"

...它是在执行下面的c#代码期间,它试图获取我的SQL Server数据以在网格中显示。中断恰好发生在表示connect.Open()的行上:

        using (var connect = Connections.mySqlConnection)
        {
            const string query = "SELECT Name, Birthdate, Narrative FROM Friends";
            using (var command = new SqlCommand(query, connect))
            {
                connect.Open();
                using (var dr = command.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        // blah
                    }
                }
            }
        }

It was inexplicable because the SQL query was very simple, I had the right connection string, and the database server was available. I decided to run the actual SQL query manually myself in SQL Management Studio and it ran just fine and yielded several records. But one thing stood out in the query results: there was some improperly encoded HTML text inside a varchar(max) type field within the Friends table (specifically, some encoded comment symbols of the sort <!-- lodged within the "Narrative" column's data). The suspect data row looked like this:

Name    Birthdate    Narrative
====    =========    ============== 
Fred    21-Oct-79    &lt;!--HTML Comment -->Once upon a time...

注意编码的HTML符号“&lt;”,它代表一个“<”字符。不知何故,它进入了数据库,而我的c#代码无法接收它!它每次都失败在connect.Open()行!在我手动编辑数据库表Friends中的一行数据并输入解码后的“<”字符之后,一切都正常了!这一行应该是这样的:

Name    Birthdate    Narrative
====    =========    ============== 
Fred    21-Oct-79    <!--HTML Comment -->Once upon a time...

我使用下面这个简单的UPDATE语句编辑了一个不好的行。但如果你有几行违规的HTML编码,你可能需要一个更详细的UPDATE语句,使用REPLACE函数:

UPDATE Friends SET Narrative = '<!--HTML Comment -->Once upon a time...' WHERE Narrative LIKE '&lt%'

因此,这个故事的寓意是(至少在我的情况下),在将HTML内容存储到数据库之前清理它,这样您就不会在第一时间得到这个神秘的SQL Server错误!(如果你需要更多信息,正确地消毒/解码你的HTML内容是另一个值得单独在StackOverflow搜索的讨论主题!)

您可以检查MS SQL Server 2014的服务状态。在Windows 7中,你可以这样做:

搜索并输入“SQL Server 2014配置管理器” 然后点击左侧菜单中的“SQL Server Service” 检查SQL Server实例的服务状态是否为“stopped”或“running” 如果已停止,请将状态改为“运行中”,并登录SQL Server Management Studio 2014

总结

要修复在运行本地应用程序与远程数据库时遇到的此问题,请使用SQL Server配置管理器为远程数据库添加别名。

细节

I had run into this problem recently when transitioning from a Windows 7 to a Windows 10 laptop. I was running a local development and runtime environment accessing our Dev database on a remote server. We access the Dev database through a server alias setup through SQL Server Client Network Utility (cliconfg.exe). After confirming that the alias was correctly setup in both the 64 and 32 bit versions of the utility and that the database server was accessible from the new laptop via SSMS, I still got the error seen by the OP (not the OP's IP address, of course).

有必要使用SQL Server Configuration Manager为远程Dev数据库服务器添加别名。把事情都解决了。

此错误主要发生在SQL服务停止时。您需要重新启动服务。要进入这个窗口,您必须像这样搜索服务-

然后搜索“SQLSERVER(MSSQLSERVER)”,并重新启动服务。

希望这能奏效。

为什么这个错误是如此烦人和嘈杂,只是因为它可以发生在不同的情况。

我已经做了上面所有的方法,但还是很糟糕。所以,在向下浏览之前,确保你和我做了同样的事情。

也许我不能立即解决你的问题,但我可以给你指明一个方向或思路(最后滑下来的那个人)。我已经开始思考我的运行程序的错误发生后,我确保实例名是明确正确的,并设置我的数据库,以允许远程控制以下的方法。之后,我怀疑我的SQL连接代码片段发生了错误。

我的问题解决方案:

检查我的sqlconnection函数

单击以查看其配置

新建连接

选择你的服务器名

对我来说,思考在联系的过程中到底发生了什么是有效的。希望我的想法能引导你改正错误。

Web中的Xml标签排列。配置很重要

第一个

<configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>

<connectionStrings>
  <add name="SqlConnectionString" connectionString="Data Source=.; Initial Catalog=TestDB; Trusted_Connection=True;" providerName="System.Data.SqlClient" />
</connectionStrings>

尝试在连接字符串的末尾添加一个和一个端口号(如1433)。

这也可能是简单的事实,你的数据库实际上不是MS SQL Server。例如,如果你的数据库实际上是MySql,你试图用System.Data.SqlClient连接它,你会得到这个错误。

到目前为止,大多数ADO的例子。Net将用于MSSQL,没有经验的用户可能不知道你不能在MySql中使用SqlConnection, SqlCommand等。

虽然所有的ADO。Net数据提供程序遵循相同的接口,您必须使用为您的数据库提供程序。

我也有这个问题,我尝试了这篇文章中建议的所有方法,但没有任何效果。最后,我通过在SQL Server中执行这个查询解决了我的问题

EXEC sp_configure 'remote access', 0 ;  
GO  
RECONFIGURE ;  
GO  

在我的情况下,MSSQLSERVER服务有一个问题,所以我重新启动服务,问题解决了。

所以我建议通过Windows键进入服务应用程序,搜索“服务”,然后找到你的Sql实例,通常是“Sql Server (MSSQLSERVER)”在Microsoft Sql Server。 右键单击服务,然后单击启动,如果禁用,则单击重新启动。

我知道这是隐藏的,但是当我移动一个数据库时,没有给NT服务\MSQLSERVER帐户权限到我移动数据库文件的目录时,我造成了这个问题。授予权限并重新启动SQLServer完成了任务。

我几乎什么都试过了。然后,我已经卸载了Malwarebytes。一种声称可以删除恶意软件的软件(通常可以)。在那之后,一切都好了。也许有人会因为同样的原因遇到同样的问题。

我也遇到过同样的问题 就我而言,我用这种方法解决了问题

步骤1:从开始菜单进入SQL server配置管理器

步骤2:启用TCP/IP

步骤3:双击TCP/IP,进入IP地址最后一个条目IP ALL,输入TCP端口1433然后应用

第四步:然后按win+r,写服务。msc打开服务,然后向下滚动,然后右键单击SQL Server (MSSQLSERVER)选择重新启动

这解决了我的问题。 即使做以上所有步骤都不能解决问题,然后简单地重新启动PC,希望它会工作。

验证用于为SQL Server实例创建会话的帐户。

重启SQL Server (MSSQLSERVER)服务即可。

如果SQL Server正在运行,您仍然得到一个错误; 当打开SQL Server时,显示的不是默认的服务器名 选项下选择以\SQLEXPRESS结尾的服务器名 服务器名称->浏览更多信息->数据库引擎选项。

对我来说,解决方案是调用互联网提供商开放端口1433。

出于某种原因,他们阻塞了端口,我甚至无法ping数据库服务器(托管在Azure上)。100%的数据包丢失。

他们打开港口后,一切又恢复了正常。

我这么晚才来,也有同样的问题。对我来说,问题来了,因为我改变了pc名。

当我试图从其他网络访问mssql服务器时,我得到了解决方案:

Open "SQL Server Configuration Manager"

Now Click on "SQL Server Network Configuration" and Click on "Protocols for Name"

Right Click on "TCP/IP" (make sure it is Enabled) Click on Properties

Now Select "IP Addresses" Tab -and- Go to the last entry "IP All"

Enter "TCP Port" 1433

为1433端口添加入站+出站规则

用于远程服务器数据库连接。 如果没有一个答案让你满意,很可能你还没有添加SQL端口1433到Windows防火墙例外。请执行以下步骤。

进入开始菜单,打开运行类型WF.msc。 在Windows防火墙高级安全。 添加入站规则。 添加1433端口。 说出你的规则。 重新启动SQL服务。

有关连接远程服务器的问题的完整指南。处理连接SQL Server数据库的故障。

I had the same issue after upgrading my Windows to Windows Pro 10 21H2. I have two SQL instances - 2014 and 2019 and I was not able to connect only to 2019 one. I restarted the computer, restarted all SQL related services. Two of the services were showing errors (SQL Server and SQL Server agent) and I was not able to start them. I could not also start these two services from C:\Windows\SysWOW64\SQLServerManager15.msc In the logs (C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER01\MSSQL\Log) I saw these lines:

Initializing the FallBack certificate failed with error code: 15, state: 29, error number: 0.
Error: 17190, Severity: 16, State: 1.
Unable to initialize SSL encryption because a valid certificate could not be found, and it is not possible to create a self-signed certificate.
Error: 17182, Severity: 16, State: 1.
TDSSNIClient initialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property. 
Error: 17182, Severity: 16, State: 1.
TDSSNIClient initialization failed with error 0x80092004, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. Cannot find object or property. 
Error: 17826, Severity: 18, State: 3.
Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
Error: 17120, Severity: 16, State: 1.
SQL Server could not spawn FRunCommunicationsManager thread. Check the SQL Server error log and the operating system error log for information about possible related problems.

原来在升级后,服务的“Log On”属性(服务属性上的第二个选项卡)被设置为NT AUTHORITY\NETWORK SERVICES。当我将其更改为“本地系统帐户”时,我能够启动服务并连接到MS SQL 2019实例。

这个msdn论坛的帖子帮助我找到了这个。

如果您正在移除迁移,您应该检查ConnectionString。

我在更改电脑名称后遇到了这个问题。 所以我只需在SQL Server Management Studio中更新服务器名:

"服务器名称" -> "浏览更多…"-> "数据库引擎" ->选择"[您的计算机名称]" -> "OK"

面临着类似的问题。对我来说,appsettings. production .json文件没有被生产服务器使用,而应用程序正在使用appsettings。json文件。系统中的“环境变量”未设置为“生产”。它将请求定向到不同的服务器。

如果Tomcat服务器或您正在使用的任何服务器宕机,则可能发生此错误。

I got this error after working at distance (VPN) for a few years. At some point in time I must have changed my DNS settings to the IP address of my home router. Now I was (again) in the same network as the server, and got the error above. the solution was to open "Network status" / "Change adapter options" and right click the active internet connection (Ethernet in my case) to get to the properties of IPv4. Under "Use the following DNS server addresses" I entered the local IP address of my server, and what do you know...! The computer contacted the domain (on the server) and SQL Server opened up.

要检查是否有相同的问题,打开cmd并输入 夜间电报/ dsgetdc:域名 [用域名交换"domainname"] 如果您得到一条消息说“获取DC名称失败:Status = 1355 0x54b ERROR_NO_SUCH_DOMAIN”,您可能是域名错误,或者您可能有这个问题。

即使我使用了正确的凭证,我也面临着这种问题。请务必执行以下操作。

确保您的sql server凭据。在sql server字段中,您必须使用计算机名。

要找到计算机名称,在您的计算机上搜索计算机名称,然后就可以找到计算机名称。然后粘贴并尝试连接。

如果无法正常工作,请尝试从服务启动计算机上的sql server。下面的截图会有帮助。

在尝试了所有的答案后,我把端口号(1433)放在服务器名后,用逗号插入连接字符串,为我工作。如下所示:

"Server=**.***.***.*\\MYSERVER,1433;Database=****;User Id=****;Password=*****;MultipleActiveResultSets=true;TrustServerCertificate=True"

azure vm用户

我已经尝试了上面所有的(所以这些仍然可能是有效的),但仍然没有wotk。

重要提示:我的只是一个游乐场服务器,所以安全性真的不是问题。所以你要做好调查,这只是一种变通方法,不是安全的方法。

确保可以ping通服务器。在我的情况下,我可以RDP,但不能ping我的服务器在Azure上。我的请求总是超时。因为似乎Azure默认阻止ICMP协议。

您可以在防火墙中添加规则。在我的例子中,无论我在那台机器上通过防火墙添加了什么,都没有任何改变。感谢@John的上述回答,这也提醒了我,我必须从Azure门户上的网络添加这个。

只要我为端口0添加了规则,我就可以远程连接了。

这个链接这个链接也很有用。