无法从 Visual Studio(或实际任何地方)连接到 AWS EC2 [英] Cannot connect to AWS EC2 from visual studio (or anywhere actually)

查看:18
本文介绍了无法从 Visual Studio(或实际任何地方)连接到 AWS EC2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 AWS 服务器(带 IIS 的 MS SQL SERVER EXPRESS 2008 R2),弹性 IP 为 54.214.8.111,安全组配置了 HTTP、MS SQL 和 FTP,我可以使用远程虚拟机连接到远程虚拟机亚马逊在控制台中为您提供的 rdp 文件.

I have an AWS server (MS SQL SERVER EXPRESS 2008 R2 with IIS), with an elastic IP of 54.214.8.111, security groups configured with HTTP, MS SQL and FTP, and I can connect to the remote virtual machine using the rdp file that amazon gives you in the console.

但是,当我尝试通过 Visual Studio 连接以测试数据库是否正常工作时,它给了我一个用户'dbuser'错误登录失败.我的 SQL Server 上有一个名为 dbuser 的用户(在服务器端)当然)具有完全访问权限等.尽管有所有指南和帮助文档,我也无法连接到服务器上的 ftp.似乎有些东西只是阻止了我的连接.我在多台计算机上尝试过同样的事情.

However when I try to connect via visual studio to test if the database is working, it gives me a "Login failed for user 'dbuser' error. I have a user called dbuser on my SQL Server (on the server side of course) with full access permissions etc. I also cannot connect to an ftp on the server, despite all guides and help doc. Something seems to be simply blocking my connection. I have tried the same thing on multiple computers.

一切似乎都配置正确,除了我怀疑服务器实例.

Everything seems to be configured correctly except I suspect the server instance.

有人可以帮忙吗?PS 我对 Web 开发还很陌生,这是我的第一台 AWS EC2 服务器.

Can anyone help? PS I'm fairly new to web development, this is my first AWS EC2 server.

[UPDATE] 我只是尝试在不同的位置创建一个新实例,同样的错误,也许我不知道如何在 EC2 上配置 SQL Server?

[UPDATE] I just tried to create a new instance in a different location, same error, maybe I don't know how to configure the SQL Server on the EC2?

推荐答案

我最近遇到了与 AWS/SQL Server 相同的连接问题,我终于解决了.

I recently had the same connectivity issue to AWS/SQL Server, I finally have it resolved.

在 AWS 上远程连接到 SQL Server 涉及 3 个主要因素:AWS --> Windows 安全性 --> SQL Server 设置/安全性.

Connecting to SQL Server remotely on AWS involves 3 main factors: AWS --> Windows Security --> SQL Server Settings/Security.

连接很容易失败,因为每个区域都有特定的要求.我会检查清单:

Connections can easily fail because each area has specific requirements. I'll go through the check-list:

AWS:

  1. 在 AWS 管理控制台中,转到安全组,单击适用于您的 Windows 服务器的组,确保 MS SQL TCP 端口 1433 对 0.0.0.0 或您的特定客户端 IP 开放.如果没有,您需要添加它.

  1. In AWS management console, go to Security Groups, click on the group that applies to your windows server, make sure MS SQL TCP port 1433 is open to 0.0.0.0 or your specific client IP. If not, you'll need to add it.

注意服务器的公共 IP

Note the Public IP of your server

窗口:

  1. RDP 到 Amazon Windows 服务器,开始 > 管理工具 > 本地安全策略
  2. 单击具有高级安全性的 Windows 防火墙、Windows 防火墙属性,单击公共配置文件"选项卡,将防火墙状态设置为开"、入站为阻止、出站为允许(或根据您的应用程序阻止).好的.
  3. 展开 Windows 防火墙(在左侧窗格中),右键单击入站规则,单击新建规则.
  4. 点击端口选项,下一步>,对于TCP,输入1433下一步>,允许连接,下一步>,下一步>,给它一个名字(SQL-PORT-ACCESS)

SQL 服务器:

  1. 使用默认的 Windows 身份验证通过 SSMS (SQL Server Management Studio) 登录到 SQL Server.
  2. 在左窗格中,右键单击顶部服务器列表(带有数据库图标,第一个列表),然后选择属性"
  3. 属性窗口,单击左侧窗格中的安全,选择SQL Server 和 Windows 身份验证"
  4. 单击连接",选中允许远程连接"选项...单击确定".
  5. 打开 SQL 配置管理器,开始 > 程序 > Microsoft SQL Server > 配置工具 > SQL Server 配置管理器
  6. SQL Server 网络配置(展开),选择 MSSQL 的协议,R-单击 TCP,选择属性(应启用 TCP)
  7. 点击 IP 地址选项卡,检查 IP1 是否启用,动态端口为 0,TCP 端口为 1433
  8. 一直向下滚动到 IPAll 部分,在 TCP 动态端口中输入 0,在 TCP 端口中输入 1433.好的...
  9. 返回左窗格,单击 SQL Server 服务,R 键单击 SQL Server 选项,然后选择重新启动".(注意:SQL Browser 服务器不影响连接,浏览器服务只列出可用服务器,使用您的特定连接参数,无需启动或担心浏览器)

测试:您不必前往远程客户端进行测试,首先尝试从服务器上的同一个 SSMS 窗口进行连接.这减少了一开始可能出错的所有其他事情,如果您可以在这里连接,您就可以确认它有效.如果它在您自己的服务器上不起作用,则问题与 Windows 安全性以及 SQL 安全性和设置有关.

TESTING: You don't have go to your remote client to test, start by trying to connect from the same SSMS window on the server. This reduces all the other things that can go wrong at first, if you can connect here, you have some confirmation that it works. If it doesn't work from your own server, the issues are related to Windows security and SQL security and setup.

  1. 在对象资源管理器 (SQL server Management Studio) 下,单击连接"> 数据库引擎...
  2. 在服务器名称中:输入您的公共 IP、逗号,然后是 1433.例如,如果您的公共 IP 是 54.4.4.4 ,请输入 54.4.4.4,1433,
  3. 选择身份验证为SQL Server",输入登录用户和密码.
  1. Under the Object Explorer (SQL server Management Studio), click "Connect" > Database Engine...
  2. In the Server name:, enter your PUBLIC IP, a comma, then 1433. Example, if your public IP is 54.4.4.4 , enter 54.4.4.4,1433,
  3. Select the authentication as "SQL Server", enter the login user and password.
  1. 如果您使用sa",请记住更改密码.
  2. 如果您的连接在本地工作,那么您可以尝试远程客户端连接.

  • 此时您知道您的 SQL 服务器和用户设置是正确的.
  • 接下来,尝试在另一台计算机上使用 SSMS.如果失败,可能防火墙需要第二次查看...

    Next, try using SSMS on another computer. If that fails, probably the firewall needs a 2nd look...

    了解问题的好地方,是否可以从 SSMS 轻松访问 SQL 日志,在左侧窗格中,展开管理,然后是 SQL Server 日志,当前日志将列出所有问题.

    Good place to understand issues, is the SQL logs easily accessible from SSMS, on the left pane, expand Management, then SQL Server Logs, current log will list any problems.

    所以,这些就是所涉及的所有部分——错过一个你会很沮丧,但首先要在测试时减少部分.

    So, those are all the parts involved -- miss one and you'll be frustrated, but start by reducing the pieces when testing.

    我能够从 Windows 设备连接到我在 AWS Windows Server/SQL Express 上的数据库......

    I was able to connect to my database on AWS Windows Server/SQL Express from a Windows device...

    祝你好运!

    这篇关于无法从 Visual Studio(或实际任何地方)连接到 AWS EC2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆