Microsoft SQL Server Native Client 10.0 登录超时已过期

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14815297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:38:29  来源:igfitidea点击:

Microsoft SQL Server Native Client 10.0 Login timeout expired

sqlsql-serversqlcmdsql-server-2008r2-express

提问by Xian Garcia

I have a freshly installed SQL Server 2008 R2 Express. I'm trying to run SQLCMDlocally (please do take note locally) but I am receiving the error:

我有一个新安装的 SQL Server 2008 R2 Express。我试图运行SQLCMD在本地(请不要注意一下本地),但我收到的错误:

Named Pipes Provider: Could not open a connection to SQL Server [2]
Sqlcmd: Error: Microsoft SQL Serve Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more informations see SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0: Login timeout expired.

命名管道提供程序:无法打开与 SQL Server [2] 的连接
Sqlcmd:错误:Microsoft SQL Serve Native Client 10.0:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。检查实例名称是否正确以及 SQL Server 是否配置为允许远程连接。有关详细信息,请参阅 SQL Server 联机丛书。
Sqlcmd:错误:Microsoft SQL Server Native Client 10.0:登录超时已过期。

Why can't I make it work? I already tried everything.

为什么我不能让它工作?我已经尝试了一切。

回答by Conor Macarthur

Maybe a little late on the draw here but for future readers with the issue: Try running Command Prompt as Administrator.

也许在这里抽签有点晚,但对于未来的读者来说,这个问题:尝试以管理员身份运行命令提示符。

回答by Mike Arney

I ran into the same problem. I used -S, instead of -s, and removed the "" before and after the servername\instance. Everything ran great after that.

我遇到了同样的问题。我使用 -S 而不是 -s,并删除了 servername\instance 前后的“”。之后一切都运行得很好。

回答by Mike.Nettle

In the named pipes properties just change the path to \\.\pipe\sql\queryinstead of default path

在命名管道属性中,只需将路径更改为\\.\pipe\sql\query而不是默认路径

回答by DRapp

I had this same thing happen to me for a client trying to setup a new SQL-Server box.

对于尝试设置新 SQL-Server 框的客户端,我也遇到了同样的事情。

Open your SQL-Server configuration manager on the machine where SQL is actually INSTALLED.

在实际安装 SQL 的机器上打开 SQL-Server 配置管理器。

Look to the SQL Native Client 10.0 Configuration. Under that is Client Protocols. You probably have TCP/IP and Named Pipes DISABLED. You need to ENABLE them.

查看 SQL Native Client 10.0 配置。下面是客户端协议。您可能禁用了 TCP/IP 和命名管道。您需要启用它们。

Sample here

样品在这里

回答by Patrick Hofman

This seems to happen too when the server or the instance can't be found.

当找不到服务器或实例时,这似乎也会发生。

It will eventually close with the reason (the first part of the error may be what misguided you):

它最终会以原因结束(错误的第一部分可能是误导了你):

Sqlcmd: Error: ... : Login timeout expired.

Sqlcmd: Error: ... : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections.

Sqlcmd: 错误: ... : 登录超时已过期。

Sqlcmd: 错误: ... : 与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。检查实例名称是否正确以及 SQL Server 是否配置为允许远程连接。

So:

所以:

  • Check the server name is correct;
  • Check the instance name is correct (and if you didn't mean to use the default instance, try remove the instance name completely);
  • Check if the server can be reached using ping, etc.
  • 检查服务器名称是否正确;
  • 检查实例名称是否正确(如果您不想使用默认实例,请尝试完全删除实例名称);
  • 检查是否可以使用 ping 等访问服务器。

回答by Kavitha

I had the same issue, the reason is because sqlcmd when typed alone without the servername, tries to connect to the default server. If you have named instance then it cannot connect to it without specifying the instance name. Work around is to make the named instance as default by changing the port as shown in this link: SQL Server, convert a named instance to default instance?

我遇到了同样的问题,原因是因为 sqlcmd 在没有服务器名称的情况下单独键入时,会尝试连接到默认服务器。如果您已命名实例,则它无法在不指定实例名称的情况下连接到它。解决方法是通过更改此链接中所示的端口来使命名实例成为默认实例: SQL Server,将命名实例转换为默认实例?