Connect to MySQL on AWS from local machine

前端 未结 6 1904
轮回少年
轮回少年 2020-12-23 11:48

I am trying to set up a dev environment on my local machine that accesses a MySQL DB on AWS, but I keep getting a \"Can\'t connect\" message.

mysql_connect(\         


        
6条回答
  •  一个人的身影
    2020-12-23 12:22

    I am on a Windows 7 machine, and had to make the following 3 changes to be able to connect to AWS RDB.

    1. VPC Security Group update in AWS Console (similar to what mikemay has above)

      • From https://console.aws.amazon.com, click on Services (top left) and choose VPC.
      • Next select Security Groups
      • Click on the Security Group which has the description "Security Group for RDS DB..."
      • On the "Inbound" tab, choose "MYSQL" in the Create a New Rule dropdown.
      • Add your IP address in CIDR format and click on Add Rule.
      • Click on Apply Rule Changes.
    2. my.cnf update in local MySQL configuration

      • Change "bind-address = 127.0.0.1" to "bind-address = 0.0.0.0"
      • Comment out "skip-networking"
    3. Turn OFF Windows Firewall

      • Go to Control Panel/System and Security/Windows Firewall and turn OFF Windows Firewall.

    After these changes, I am able to connect through both

    • MySQL WorkBench using Database->Connect to Database
    • Command Prompt with

      mysql.exe -h  -U  -P  -p
      

提交回复
热议问题