2016-09-14 309 views
0

我刚刚在N.Virginia &中创建了RDS实例,尝试使用Navicat连接该数据库。AWS RDS:使用Navicat连接

但是我无法连接它。

经过互联网搜索后,我才知道我们需要配置安全组。但在我的情况下有一个通知:

Your account does not support the EC2-Classic Platform in this region. DB Security Groups are only needed when the EC2-Classic Platform is supported. Instead, use VPC Security Groups to control access to your DB Instances. Go to the EC2 Console to view and manage your VPC Security Groups. For more information, see AWS Documentation on Supported Platforms and Using RDS in VPC. 

请帮我解决问题。 N.Virginia也是AWS自动分配的。在Free-tier中选择N.Viginia是很好的选择。

回答

2

我可能不建议从您的本地系统获得RDS数据库的直接链接;我可能会建议只能以ec2实例登录,但让我们看看

当你在RDS中创建你的数据库(将是Oracle,mysql ...)时,你定义了/如何访问它。

  1. 让您的实例公开访问

enter image description here

选择是,如果你想托管数据库实例的VPC外的EC2实例和设备连接到数据库实例。如果选择否,则Amazon RDS将不会为数据库实例分配公有IP地址,并且VPC外部的任何EC2实例或设备都不能连接。如果选择是,则还必须选择一个或多个VPC安全组,以指定哪些EC2实例和设备可以连接到数据库实例。

如果您说yes您可以从本地笔记本电脑连接到您的数据库。如果你说no好,只有从同一VPC启动的ec2实例才能访问它。

  • 定义您的VPC安全组
  • 如果您选择现有VPC,你可能有一些定义的安全组。如果你没有VPC或没有现有的安全组。 Security groups可以看作是一个防火墙,您可以定义打开哪个端口以及谁可以访问。

    如果您离开创建新的安全组数据库将启动并创建一个新的安全组。您可以从AWS控制台查看(确保选择您创建数据库的相同区域)或直接https://console.aws.amazon.com/vpc/home?region=us-east-1#securityGroups :(在您使用其他方式时替换区域)。创建新的安全组将被命名为rds-launch-wizard

    enter image description here

    编辑安全组,并检查入站规则,默认情况下,AWS将创建一个新的规则打开端口(取决于DB)到你的IP,您可以将其更改为打开更多IP或进一步限制。

    安全规则预先给RDS支持的数据库(甲骨文,MS SQL和MySQL /极光),所以只是从列表中选择合适的项目,当您添加一个新的入站规则

    当数据库实例已经启动你可以查看端点

    enter image description here

    ,因此你可以从当地的笔记本电脑连接

    $ mysql -u <username> -p -h <database>.cnrsdab7emat.us-east-1.rds.amazonaws.com 
    Enter password: 
    Welcome to the MySQL monitor. Commands end with ; or \g. 
    Your MySQL connection id is 21 
    Server version: 5.6.10 MySQL Community Server (GPL) 
    
    Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 
    
    Oracle is a registered trademark of Oracle Corporation and/or its 
    affiliates. Other names may be trademarks of their respective 
    owners. 
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
    
    mysql> status 
    -------------- 
    mysql Ver 14.14 Distrib 5.6.22, for osx10.10 (x86_64) using EditLine wrapper 
    
    Connection id:  21 
    Current database: 
    Current user:  <username>@90.27.155.48 
    SSL:   Not in use 
    Current pager:  stdout 
    Using outfile:  '' 
    Using delimiter:  ; 
    Server version:  5.6.10 MySQL Community Server (GPL) 
    Protocol version:  10 
    Connection:   <database>.cnrsdab7emat.us-east-1.rds.amazonaws.com via TCP/IP 
    Server characterset: latin1 
    Db  characterset: latin1 
    Client characterset: utf8 
    Conn. characterset: utf8 
    TCP port:   3306 
    Uptime:   6 min 33 sec 
    
    Threads: 5 Questions: 2656 Slow queries: 0 Opens: 89 Flush tables: 1 Open tables: 82 Queries per second avg: 6.758 
    -------------- 
    
    mysql> 
    

    如果你喜欢使用Navicat连接,你应该能够设置建立相同的连接。