Connecting to Amazon RDS MySql remotely

五迷三道 提交于 2021-01-27 05:40:59

问题


I'm trying to connect to MySql on Amazon RDS from my computer, using MySql WorkBench, or HeidiSql or even the console Mysql.exe and i'm getting this error all the time:

ERROR 2003 (HY000): Can't connect to MySQL server on 'MY-SERVER-NAME' (10060)

  1. In the Security group of the instance I created a new Inbound rule that allows all traffic, and applied it, and still - same error.
  2. I have no active Firewall on my computer, and have good internet access
  3. I am able to access the DB from the Amazon EC3 server, there I am connecting using HeidiSql, and the exact same settings (host, username, password) is just not working on my computer

Still, nothing is working. I'm pretty sure that my security groups is configured to allow outside connections, as can be seen on the next screenshot, there is another place with firewall rules? Screenshot of SecurityGroups


回答1:


I was having the same problem when using an RDS instance on a VPC that I wanted to connect to remotely. To fix the problem, I needed to do the following:

  • Go to the VPC Management Console in AWS
  • Go to Internet Gateways (on the left side)
  • Create and attach an internet gateway to my VPC. Make note of the ID of this gateway.
  • Go to Route Tables
  • Edit the route table associated with the subnets associated with your RDS instance
  • Add a route:
    • Destination: 0.0.0.0/0
    • Target: ID of your Internet Gateway

I didn't have this route in my table because I created my VPC manually and without using the wizard, but if you use the wizard it creates this route for you automatically.

Note: This assumes that your security groups are already configured to allow your IP to connect.




回答2:


The 2003 error is the Access-Denied Error I would be willing to bet that you haven't configured the RDS to accept your IP address.

This can be done by going to DB Security Groups -> Click Default -> and add a new CIDR/IP range. I believe that if you set it to 0.0.0.0/0 it will accept all ip addresses




回答3:


I use SQLyog for connecting to Amazon RDS from my machine.

You can refer this blog: http://blog.webyog.com/2009/11/06/amazon-rds-the-beginners-guide/




回答4:


The security group settings are just firewall rules. If you can telnet on your configured MySQL port from the host you are having problems then you don't have the security group issue.

Chances are the MySQL grants are not allowing outside IPs. If you know the root user/password and you can use it to connect from your EC2 instance that works, make sure the user you are using to connect from outside has the right privileges. Here is the doc on how to add a new privilege or create a new user:

http://dev.mysql.com/doc/refman/5.1/en/grant.html http://dev.mysql.com/doc/refman/5.1/en/adding-users.html http://dev.mysql.com/doc/refman/5.0/en/access-denied.html




回答5:


Did you assign the security group to your RDS instance? If you didn't modify the default security group, then you need to add your security group to your RDS instance.




回答6:


In my case, my company had two different network connections. When I went to google and searched "What is my IP?" I got one answer; 209.x.y.z. When I went to checkip.amazonaws.com I got another answer; 199.a.b.c.

I had already added VPC Security Group Rules for 209.x.y.z and it turned out I needed them for 199.a.b.c.

Adding rules for 199.a.b.c fixed the issue.




回答7:


I had same problem as you, all firewall have been opened, but still can not access to my RDS mysql remotely from my local machine. my finally workout is there is a "Public Accessibility" option on your RDS database. default is "No", after I tick it to "YES", everything is running smoothly now.



来源:https://stackoverflow.com/questions/22079211/connecting-to-amazon-rds-mysql-remotely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!