无法远程连接到 SQL Server 实例

发布于 2024-11-28 10:02:51 字数 1227 浏览 0 评论 0 原文

我正在尝试从本地计算机上的 SQL Server Management Studio 访问 VPS 上的 SQL Server 实例。它不起作用(我得到的错误是:

发生网络相关或特定于实例的错误 建立与 SQL Server 的连接。找不到服务器或 无法访问。验证实例名称是否正确 SQL Server 配置为允许远程连接。

我认为这是因为我需要配置数据库引擎以允许远程连接(如果我错了,请纠正我!)。因此,我找到了这个分步指南来帮助我做到这一点: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ 我必须指出第10点导游和我现在被困住了!我的 VPS 上没有安装 SQL Server Management Studio。不管怎样,这给我留下了两个选择:

  1. 安装 SSMS
  2. 寻找另一种方法来完成指南中第 10 点以后的操作,而无需安装 SSMS

我尝试使用 Web 平台安装程序在我的 VPS 上安装 SSMS,但它一直失败。我不知道为什么它会失败,因为它似乎没有给出原因。有谁知道我如何以不同的方式允许远程连接?

我的 VPS 上安装的 SQL Server 版本是 SQL Server 2008 R2 Express。

更新

我尝试禁用我的笔记本电脑和 VPS 上的防火墙,看看是否是防火墙问题。这对错误消息没有影响。

另一个更新:

现在能够安装 SSMS(我直接从网站安装而不是使用 WPI),我已经能够检查服务器是否配置为允许远程连接(我去了SSMS,连接到 SQL Server 实例,右键单击该连接,单击“属性”,进入“连接”选项卡,“允许远程连接到此服务器”已勾选)。

解决方案

感谢大家帮助我找到这个解决方案!我终于成功让它发挥作用了!我按照 Filip De Vos 的建议打开了 VPS 上防火墙中的端口,然后收到了不同的错误消息。这促使我进一步调查,我发现我使用了错误的凭据登录!所以我为 sa 用户设置了一个密码,并且我已经成功地使用它登录了!再次感谢!

I’m trying to access the SQL Server instance on my VPS from SQL Server Management Studio on my local machine. It’s not working (the error I’m getting is:

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.

I think this is because I need to configure the database engine to allow remote connections (correct me if I’m wrong!). So I’ve found this step-by-step guide to help me do that: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ I’ve got to point 10 in the guide and I am now stuck! I don’t have SQL Server Management Studio installed on my VPS. Anyway, this has left me with two options:

  1. Install SSMS
  2. Find another way to do point 10 onwards in the guide without having SSMS installed

I tried installing SSMS on my VPS using the Web Platform Installer but it keeps failing. I don’t know why it’s failing because it doesn’t seem to give a reason why. Does anyone know how I could allow remote connections a different way?

The version of SQL Server installed on my VPS is SQL Server 2008 R2 Express.

Update:

I have tried to disable the firewall on both my laptop and VPS to see if it is a firewall issue. This made no difference to the error message.

Another Update:

Having now been able to install SSMS (I installed directly from the website rather than using the WPI), I have been able to check that the server is configured to allow remote connections (I went to SSMS, connected to the SQL Server instance, right-clicked on the connection, clicked Properties, went to the Connections tab. "Allow remote connections to this server" is already ticked).

SOLUTION

Thanks to everyone for helping me get to this solution! I've finally managed to get it to work! I followed Filip De Vos's advice and opened the ports in the Firewall on my VPS and then I received a different error message. This led me to investigate further and I found that I was using the wrong credentials to login! So I've set a password for the sa user and I've managed to login using that! Thanks again!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

情魔剑神 2024-12-05 10:02:52

就我而言,上面的任何内容都不起作用,因为 ESET 安全性有自己的防火墙层,只有在我禁用它之后,事情才开始起作用(并且在执行了其他人建议的操作之后)。

In my case, nothing from above worked, because ESET security had its own layer of firewall, and only after I disabled that, the things started working (and after doing the things that other suggested).

小姐丶请自重 2024-12-05 10:02:52

确保打开 service.msc 中的每个服务

嗨,这是我的情况,我不是 IT 专家,所以我不太明白为什么会这样,但你可以检查一下。
错误消息

首先,打开“运行”框(Win + R),然后键入“service.service”。 msc”并按 Enter 键,它将打开一个服务表单。

接下来,找到下图中的服务,右键单击,选择“属性”,然后按“启动”。
您需要运行这些服务

我不太明白,但它对我有用,祝你好运。

Make sure to turn on every services there are in service.msc

Hi, this is my case, i'm not an IT expert so i don't really understand why this works, but you can check it out.
Error Message

First, Open "Run" box (Win + R), then type "service.msc" and press enter, it'll open a Services Form.

Next, find the services in the picture below, right click, choose "Properties" and press "Start".
You need to Run these Services

I don't understand clearly, but it works for me, goodluck.

笑饮青盏花 2024-12-05 10:02:51
  • 要启用混合身份验证,您可以更改以下注册表项:

    <预置><代码> HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\LoginMode

    将该值更新为 2 并重新启动 Sql Server 服务以允许混合身份验证。 请注意,可能需要更新 MSSQL.1 以反映您尝试更改的 SQL Server 实例的编号。

  • 连接错误的原因可能是服务器上安装的病毒扫描程序导致块sqlserver.exe

  • 另一个原因可能是 SQL Server Browser 服务未运行。当此服务未运行时,您无法连接命名实例(当它们使用动态端口时)。

  • 也有可能 Sql Server 未设置为侦听 TCP 连接,而仅允许命名管道。

  1. 在“开始”菜单中,打开“程序”>“程序”。微软 SQL Server 2008 >
    配置工具> SQL Server 外围应用配置
  2. 在外围应用配置实用程序中,单击链接“SQL Server
    配置管理器”
  3. 展开“SQL Server 网络配置”并
    选择协议。
  4. 启用 TCP/IP。如果您需要命名管道,那么您可以
    也在这里启用它们。
  • 最后但并非最不重要的一点是,Windows 防火墙需要允许连接到 SQL Server。
  1. 当您使用“动态端口”系统时,请为 sqlserver.exe 添加例外。
  2. 否则,您可以为 SQL Server 端口设置例外(默认端口 tcp/1433)。
  3. 同时为 SQL Server 浏览器添加例外。 (端口 udp/1434)

更多信息:

最后一点,SqlLocalDB 仅支持命名管道,因此您无法通过网络连接到它。

  • To enable mixed authentication you can change the following registry key:

      HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\LoginMode
    

    Update the value to 2 and restart the Sql Server service to allow mixed authentication. Note that MSSQL.1 might need to be updated to reflect the number of the SQL Server Instance you are attempting to change.

  • A reason for connection errors can be a virus scanner installed on the server which blocks sqlserver.exe.

  • Another reason can be that the SQL Server Browser service is not running. When this service is not running you cannot connect on named instances (when they are using dynamic ports).

  • It is also possible that Sql Server is not setup to listen to TCP connections and only allows named pipes.

  1. In the Start Menu, open Programs > Microsoft SQL Server 2008 >
    Configuration Tools > SQL Server Surface Area Configuration
  2. In the Surface Area Configuration utility, click the link "SQL Server
    Configuration Manager"
  3. Expand "SQL Server Network Configuration" and
    select Protocols.
  4. Enable TCP/IP. If you need Named Pipes, then you can
    enable them here as well.
  • Last but not least, the Windows firewall needs to allow connections to SQL Server
  1. Add an exception for sqlserver.exe when you use the "Dynamic Port" system.
  2. Otherwise you can put exceptions for the SQL Server ports (default port tcp/1433)
  3. Also add an exception for the SQL Server Browser. (port udp/1434)

More information:

As a last note, SqlLocalDB only supports named pipes, so you can not connect to it over the network.

十雾 2024-12-05 10:02:51

除了在 Services.msc 中将 SQL Server Browser 服务配置为自动并启动该服务之外,我还必须在以下位置启用 TCP/IP:SQL Server 配置管理器 | SQL Server 网络配置 | [实例名称] 的协议 | TCP/IP

在此输入图像描述

In addition to configuring the SQL Server Browser service in Services.msc to Automatic, and starting the service, I had to enable TCP/IP in: SQL Server Configuration Manager | SQL Server Network Configuration | Protocols for [INSTANCE NAME] | TCP/IP

enter image description here

冷默言语 2024-12-05 10:02:51
  1. 在您的 VPS 上启动 SQL Server 配置管理器。

  2. 查看 SQL Server 网络配置。确保 TCP/IP 已启用

  3. 接下来看看 SQL Server 服务。确保 SQL Server Browser 正在运行。

  4. 重新启动 SQL Server 实例的服务。

  1. Launch SQL Server Configuration Manager on your VPS.

  2. Take a look at the SQL Server Network Configuration. Make sure that TCP/IP is enabled.

  3. Next look at SQL Server Services. Make sure that SQL Server Browser is running.

  4. Restart the service for your instance of SQL Server.

合久必婚 2024-12-05 10:02:51

我遇到了同样的问题,我的防火墙配置正确,在 SQL Server 配置管理器中启用了 TCP/IP,但我仍然无法从托管它的计算机外部访问我的 SQL 数据库。我发现解决方案是 SQL Server Browser 在“服务”中默认被禁用(并且在 SQL Server 配置管理器中没有可用的选项来启用它)。

我通过“控制面板”启用它>管理工具>然后双击 SQL Server Browser 服务。在“常规”选项卡中,使用下拉列表将启动类型设置为“自动”。然后返回 SQL Server 配置管理器并检查 SQL Server 浏览器是否已启用。希望这有帮助。
输入图片此处描述

I had the same issue where my firewall was configured properly, TCP/IP was enabled in SQL Server Configuration Manager but I still could not access my SQL database from outside the computer hosting it. I found the solution was SQL Server Browser was disabled by default in Services (and no option was available to enable it in SQL Server Configuration Manager).

I enabled it by Control Panel > Administrative Tools > Services then double click on SQL Server Browser. In the General tab set the startup type to Automatic using the drop down list. Then go back into SQL Server Configuration Manager and check that the SQL Server Browser is enabled. Hope this helps.
enter image description here

空城旧梦 2024-12-05 10:02:51
  1. 打开 SQL Server 配置管理器...
    2.检查TCP和UDP是否正在运行....
    3.如果没有运行,请启用它们并检查 SQL Server 浏览器是否正在运行。如果没有运行,请将其打开......

  2. 接下来您必须检查 TCP 和 UDP 正在使用哪些端口。您必须从 Windows 防火墙打开这些端口......

5.单击此处查看在 Windows 防火墙中打开特定端口的步骤....

  1. 现在 SQL Server 已准备好通过 LAN 访问.......< /p>

  2. 如果您想远程(通过互联网)访问它,您必须做另一项工作,即“端口转发”。您已打开路由器上 SQL Server 中使用的 TCP 和 UDP 端口。现在路由器的配置有所不同。如果您向我提供您的路由器的详细信息(即公司名称和版本),我可以向您展示如何转发特定端口的步骤。

  1. Open the SQL Server Configuration Manager....
    2.Check wheather TCP and UDP are running or not....
    3.If not running , Please enable them and also check the SQL Server Browser is running or not.If not running turn it on.....

  2. Next you have to check which ports TCP and UDP is using. You have to open those ports from your windows firewall.....

5.Click here to see the steps to open a specific port in windows firewall....

  1. Now SQL Server is ready to access over LAN.......

  2. If you wan to access it remotely (over internet) , you have to do another job that is 'Port Forwarding'. You have open the ports TCP and UDP is using in SQL Server on your router. Now the configuration of routers are different. If you give me the details of your router (i. e name of the company and version ) , I can show you the steps how to forward a specific port.

尐偏执 2024-12-05 10:02:51

禁用防火墙并尝试连接。

如果有效,则启用防火墙和

Windows Defender 防火墙 ->高级设置->入站规则(右键)->新规则->端口->允许端口 1433(公共和私有)->添加

对出站规则执行相同操作。

然后再试一次。

Disable the firewall and try to connect.

If that works, then enable the firewall and

Windows Defender Firewall -> Advanced Settings -> Inbound Rules(Right Click) -> New Rules -> Port -> Allow Port 1433 (Public and Private) -> Add

Do the same for Outbound Rules.

Then Try again.

莫相离 2024-12-05 10:02:51

我最近从 SQL 2008 R2 升级到 SQL 2012 并遇到了类似的问题。问题出在防火墙上,更具体地说是 SQL SERVER 的防火墙规则。自定义规则指向 SQL Server 的早期版本。试试这个,打开 Windows 防火墙 > 高级设置。找到 SQL Server 规则(它可能有自定义名称)。右键单击并转到属性,然后转到程序和服务选项卡。如果选择“程序”-“此程序”,您应该浏览找到正确版本的 sqlserver.exe。

I recently upgraded from SQL 2008 R2 to SQL 2012 and had a similar issue. The problem was the firewall, but more specifically the firewall rule for SQL SERVER. The custom rule was pointed to the prior version of SQL Server. Try this, open Windows Firewall>Advanced setting. Find the SQL Server Rule (it may have a custom name). Right-Click and go to properties, then Programs and Services Tab. If Programs-This program is selected, you should browse for the proper version of sqlserver.exe.

浴红衣 2024-12-05 10:02:51

如果您有多个实例...那么请确保所有实例的端口号都是唯一的,并且除了默认实例之外没有人的端口号是 1433...

If you have more than one Instances... Then make sure the PORT Numbers of all Instances are Unique and no one's PORT Number is 1433 except Default One...

挽你眉间 2024-12-05 10:02:51

打开 SQL Server 配置管理器。

单击“SQL Server Services”,在右侧选择您在安装过程中创建的服务器(默认情况下其状态为“停止”),单击一次,工具栏上应出现一个播放按钮。单击该播放按钮,等待其状态变为“正在运行”。现在你很好了。

打开SQL Server Management Studio;将“服务器类型”切换为“数据库引擎”,将“身份验证”切换为“SQL Server 身份验证”。默认登录名是“sa”,密码是您在创建服务器时选择的密码。现在你可以开始工作了。

Open SQL Server Configuration Manager.

Click SQL Server Services, on the right side choose the server you've created during installation (by default its state is stopped), click once on it and a play button should appear on the toolbar. Click on this play button, wait til its state turns to "Running". Now you're good.

Open SQL Server Management Studio; switch the "Server Type" to "Database Engine" and "Authentication" to "SQL Server Authentication". The default login is "sa", and the password is the password that you chose on creating the server. Now you're good to work.

疑心病 2024-12-05 10:02:51

就我而言,问题是由计算机名称之间的不一致引起的。在系统设置中,我的计算机被命名为一些长名称,但显然用于某些特定通信的名称已被修剪。

我将设置中的名称更改为较短的名称,并且成功了。

In my case the problem was caused by the inconsistency between computer names. In system settings my computer was named with some long name, but apparently the name used for some certain communications was trimmed.

I changed the name in the settings to a shorter one and it worked.

英雄似剑 2024-12-05 10:02:51

我已经构建了控制台应用程序和 UWP 应用程序,并且我的控制台连接正常,但我的 UWP 则不然。经过几个小时的头撞桌子后 - 如果它是托管 SQL 数据库的 Intranet 服务器,则必须启用“专用网络(客户端和服务器)”。它位于 Package.appxmanifest 和“功能”选项卡下。屏幕截图

I had built both a console app and a UWP app and my console connected fine, but not my UWP. After hours of banging my head against the desk - if it's a intranet server hosting the SQL database you must enable "Private Networks (Client & Server)". It's under Package.appxmanifest and the Capabilities tab.Screenshot

夜雨飘雪 2024-12-05 10:02:51

在下载最新版本并更新您的 sql server 以修复 Sql Server 2012 上的 TLS 1.2 错误之前。有关详细信息,请检查 这里

Before download the last version and update your sql server to fix errors of TLS 1.2 on Sql Server 2012. For more information, check here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文