11
votes

I am new to AWS RDS. I have created RDS instance.But i dont know, how can i connect this DB. I tried like this

mysql -h awsinstanamehere.rds.amazonaws.com -P 3306 -u username -p

After i entered password and i am getting some error like this

ERROR 2003 (HY000): Can't connect to MySQL server on 'awsinstanamehere.rds.amazonaws.com' (110)

Need to set any security setting in AWS console?

Note: I want to import tables for that DB

Thanks

5

5 Answers

12
votes

RDS has a security group - in the AWS console, RDS, there's an entry for security groups.

If you didn't explicitly create a security group, you are probably using "default". You should probably have one group per RDS instance.

You will need to make sure that port 3306 is open to your local network, as well as whatever application you will be using to connect to it. You can allow access by IP or by security group.

0
votes

I was having a little trouble with these answers so here are the steps I followed to get it working...

  1. Logged in via ssh to my ec2 instance.
  2. typed this command, curl canhazip.com
  3. copied the ip address that was returned
  4. went to my VPC Dashboard in aws
  5. clicked on Security Groups in the left column
  6. clicked on the checkbox next to one of the security groups
  7. clicked Edit under the Inbound Rules tab
  8. added this rule : MySQL/Aurora (3306) TCP (6) 3306 [IP from #2]/32
  9. saved

I did this for every security group until the mysql connection worked from the command line, then deleted all of the ones that I didn't need, and retested to make sure I could still connect.

0
votes

Same error, but in my case the problem wasn't related to security groups.
I forgot to add an additional route to the route table of the subnets.

See below the 2nd route where the internet gateway was added as the target for all non local traffic (outside the VPC):

enter image description here

-1
votes

By default security group defined by AWS is not configured for publicly available inbound source. You will have to modify the security group inbound source ip to 0.0.0.0/0

-1
votes

It worked for me when I added the port 3306, while it was only the 1433 it was not working....

so the security group was created like this

security group vpc-XXXXXX

MY SQL / TCP / 1433 / 0.0.0.0/0
MY SQL / TCP / 1433 / ::/0
MTSQL/Aurora / TCP / 3306 / 0.0.0.0/0
MSSQL/Autora / TCP / 3306 / ::/0

following the headers TYPE / Protocol / Port Range / Source