简体   繁体   English

为什么对SQL Server Express Edition 2014的远程访问失败?

[英]Why does remote access to SQL Server Express Edition 2014 fail?

I've just installed SQL Server 2014 Express edition on my W7 work station. 我刚刚在W7工作站上安装了SQL Server 2014 Express版。 Please help me to connect to the new instance from my old kind Windows XP. 请帮助我从旧的Windows XP连接到新实例。 Command line sessions below provide details (remote access is allowed). 下面的命令行会话提供了详细信息(允许远程访问)。 Google search did not help much. Google搜索并没有太大帮助。

On computer that hosts the new instance (10.0.0.100, "server" workstation) both instances are accessible: 在承载新实例的计算机(10.0.0.100,“服务器”工作站)上,两个实例均可访问:

C:\1>hostname
FDE-HQ-WK4
C:\1>sqlcmd -Sfde-hq-wk4\sql2014 -Usa -Pdbasql -Q"select @@version select @@servername"
----------------------------------------------------------------------------------------

Microsoft SQL Server 2014 - 12.0.2000.8 (Intel X86)
        Feb 20 2014 19:20:46
        Copyright (c) Microsoft Corporation
        Express Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
----------------------------------------------------------------------------------------
FDE-HQ-WK4\SQL2014

C:\1>sqlcmd -Sfde-hq-wk4 -Usa -Pdbasql -Q"select @@version select @@servername"
----------------------------------------------------------------------------------------
Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)
        Mar 29 2009 10:27:29
        Copyright (c) 1988-2008 Microsoft Corporation
        Express Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
----------------------------------------------------------------------------------------
FDE-HQ-WK4\SQLEXPRESS

The next session is on a computer (10.0.0.113 "client" workstation) that physically shares my desk with the previous one, old instance works fine but connection to the new one fails: 下一个会话位于一台计算机(10.0.0.113“客户端”工作站)上,该计算机与上一个物理共享我的办公桌,旧实例可以正常工作,但连接到新实例失败:

d:\1>sqlcmd -Sfde-hq-wk4 -Usa -Pdbasql -Q"select @@version select @@servername"
-------------------------------------------------------------------------------------------------
Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)
        Mar 29 2009 10:27:29
        Copyright (c) 1988-2008 Microsoft Corporation
        Express Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
-------------------------------------------------------------------------------------------------
FDE-HQ-WK4\SQLEXPRESS

d:\1>sqlcmd -Sfde-hq-wk4\sql2014 -Usa -Pdbasql -Q"select @@version select @@servername"
HResult 0xFFFFFFFF, Level 16, State 1
SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connectio
the default settings SQL Server does not allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

d:\1>

When connecting to a named instance using the TCP sockets library, the client will use two methods to determine what port to connect to. 使用TCP套接字库连接到命名实例时,客户端将使用两种方法来确定要连接到的端口。

  1. It will connect to TCP 1433 to talk to the default instance of SQL Server. 它将连接到TCP 1433以与SQL Server的默认实例进行通信。 One of the duties of the default instance is to keep track of all named instances and the ports they are currently listening on. 默认实例的职责之一是跟踪所有命名实例以及它们当前正在侦听的端口。
  2. It will connect to UDP 1434 to talk to the SQL Browser service. 它将连接到UDP 1434以与SQL Browser服务进行通信。 One of its duties of SQL Browser is to keep track of all named instances and the ports they are currently listening on. SQL Browser的职责之一是跟踪所有命名实例及其当前正在侦听的端口。

If the client cannot connect to either of these then the connection attempt will fail. 如果客户端无法连接到任何一个,则连接尝试将失败。 In this case, you are required to specify the port number in the connection. 在这种情况下,您需要在连接中指定端口号。 In your case. 就你而言。 sqlcmd -S fde-hq-wk4\\sql2014 fails because neither the default instance nor SQL Browser is running. sqlcmd -S fde-hq-wk4\\sql2014失败,因为默认实例和SQL Browser均未运行。

Your answer in fact suggests you are running a named instance, fde-hq-wk4\\sql2014, on the default port. 实际上,您的答案表明您正在默认端口上运行命名实例fde-hq-wk4 \\ sql2014。 This named instance does not keep track of instances and port allocations. 此命名实例不跟踪实例和端口分配。 Thus, your "unfortunate behaviour" sounds like a result of your unfortunate choice of installation. 因此,您的“不幸行为”听起来像是您不幸选择安装的结果。

As to why the connection works when running locally, in that case it is probably using the SHared Memory network library. 至于为什么在本地运行时该连接起作用的原因,在这种情况下,它可能使用了SHared Memory网络库。

Short answer - if you don't want to run SQL Browser (it sends a fair amount of broadcast traffic, so most people leave it disabled) then hard code the port numbers in your connection strings. 简短的答案-如果您不想运行SQL Browser(它发送大量广播流量,因此大多数人都将其禁用),然后在连接字符串中硬编码端口号。

I agree with Greenstone Walker. 我同意格林斯通·沃克的观点。 By default SQL Express do not enable the TCP/IP protocol. 默认情况下,SQL Express不启用TCP / IP协议。 You can login to SQL server configuration manager , select the protocols under your installed instance and check if TCP/IP is enabled. 您可以登录到SQL Server配置管理器,选择已安装实例下的协议,然后检查是否启用了TCP / IP。 If not enabled, enable it and check the settings. 如果未启用,请启用它并检查设置。 You will need to restart the SQL services to apply the changes. 您将需要重新启动SQL服务以应用更改。

The following does work: 以下工作正常:

C:\1>sqlcmd -Sfde-hq-wk4\sql2014 -Upacrat -Ppacratdba -Q "select @@version selec
t @@servername"
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Inte
...
 SQL Server Books Online..

C:\1>sqlcmd -Sfde-hq-wk4\sql2014,1433 -Upacrat -Ppacratdba -Q "select @@version
select @@servername"
------------------------------------------------------------
Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)
        Mar 29 2009 10:27:29
        Copyright (c) 1988-2008 Microsoft Corporation
        Express Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
------------------------------------------------
FDE-HQ-WK4\SQLEXPRESS

C:\\1> C:\\ 1>

Thanks everybody, and please keep in mind this unfortunate Express Edition behavior. 谢谢大家,并请记住这种不幸的Express Edition行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM