2016-09-14 299 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連接,你應該能夠設置建立相同的連接。