简体   繁体   English

允许SQL Server远程连接

[英]Allow SQL Server Remote Connection

I need to connect to remote SQL Server by an ip address with a port. 我需要通过带有端口的IP地址连接到远程SQL Server。

But when I ping to the ip address then that reply as well. 但是,当我ping到IP地址时,该回复也是如此。 But when I try to establish the connection that failed. 但是当我尝试建立连接失败时。

I tried with Management Studio and with command prompt too. 我也尝试了Management Studio和命令提示符。

My command was: 我的命令是:

sqlcmd -S [IP],[port] -U [user] -P [password]

The error report as follows : 错误报告如下:

HResult 0x274C, Level 16, State 1 HResult 0x274C,级别16,状态1
TCP Provider: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. TCP提供程序:连接尝试失败,因为一段时间后连接方未正确响应,或者建立连接失败,因为连接的主机未能响应。

Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Sqlcmd:错误:Microsoft SQL Server本机客户端10.0:建立与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. 检查实例名称是否正确以及SQL Server是否配置为允许远程连接。 For more information see SQL Server Books Online.. 有关更多信息,请参见SQL Server联机丛书。
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired. Sqlcmd:错误:Microsoft SQL Server本机客户端10.0:登录超时已过期。

I would like to know that 我想知道

  1. is there any missing steps from my client side for which I am unable to establish the connection? 我的客户端有没有丢失的步骤无法建立连接?

  2. or this is the matter of server configuration (Allowing remote connection) 还是这是服务器配置的问题(允许远程连接)

It looks like you are actually missing the database name you would like to connect to: 看来您实际上缺少要连接的数据库名称:

EX: sqlcmd -S [IP],[port]\[DBNAME] -U [user] -P [password] 例如: sqlcmd -S [IP],[port]\[DBNAME] -U [user] -P [password]

In addition to configuring the Windows Firewall to allow incoming connections on TCP Port 1433, you will need to start the SQL Server Browser service. 除了将Windows防火墙配置为允许TCP端口1433上的传入连接外,您还需要启动SQL Server Browser服务。 This service can be found on the Start Menu - Microsoft SQL Server 2008 R2 - Configuration Tools - SQL Server Configuration Manager. 可以在“开始”菜单-Microsoft SQL Server 2008 R2-配置工具-SQL Server配置管理器上找到此服务。 Once there, click SQL Server Services on the left, then SQL Server Browser on the right. 到达后,单击左侧的“ SQL Server服务”,然后单击右侧的“ SQL Server浏览器”。 This is disabled by default. 默认情况下禁用此功能。

  1. Right click SQL Server Browser and choose Properties 右键单击“ SQL Server浏览器”,然后选择“属性”。
  2. Click the Service Tab 单击服务选项卡
  3. For property Start Mode, choose Automatic 对于属性“开始模式”,选择“自动”
  4. Click Apply 点击应用
  5. Click the Log On tab 单击登录选项卡
  6. Choose the appropriate account for log on (I used built in service account) 选择适当的帐户进行登录(我使用内置的服务帐户)
  7. Click Apply 点击应用
  8. Click Start 点击开始
  9. Click OK 点击确定

This solved my problem on Windows Server 2008 R2 with SQL Server 2008 R2 Express Edition. 这解决了我在带有SQL Server 2008 R2 Express Edition的Windows Server 2008 R2上的问题。

Check the firewall settings on the server that is actively hosting the database. 检查正在主动托管数据库的服务器上的防火墙设置。 By default, Windows Server will block all remote connections to the Database Server. 默认情况下,Windows Server将阻止与数据库服务器的所有远程连接。

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

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