Rhea
Rhea

Reputation: 185

ERROR 2003 (HY000): Can't connect to MySQL server on AWS RDS

I created an external user with '%' hostname to allow remote access. I get the following error while connecting the local MySQL to remote AWS RDS:

ERROR 2003 (HY000): Can't connect to MySQL server on 'instance.cvxqy8tbi2bk.us-east-1.rds.amazonaws.com' (110).

I tried commenting the #bind-address = localhost but no solution. Any pointers for this?

Upvotes: 11

Views: 35434

Answers (10)

Praful Kamble
Praful Kamble

Reputation: 11

Answer:

  1. Simply open the port of the security groups on both side EC2 and RDS.
  2. Go to security groups then edit inbound rules then select mysql, port 3306,source anywhere-ipv4

Upvotes: 1

Karthikeyan VK
Karthikeyan VK

Reputation: 6006

This is an access problem.

You need to go to the security group of your database, click on the security group and then navigate to Security Groups and select inbound rules

enter image description here

Click on Edit Inbound rules

enter image description here

Add 2 new rules with Type as "All Traffic" and "Anywhere Ipv4" & "Anywhere Ipv4" for Source.

enter image description here

Save once done. Now you can connect to the MySQL DB

Upvotes: 1

Bikash Nath
Bikash Nath

Reputation: 33

If the DB instance is in a private subnnet you should be able to connect from the EC2 instance in private VPC after Set up EC2 connection when both EC2 and RDS are in same VPC.

mysql -h <endpoint> -P 3306 -u <mymasteruser> -p

To connect with RDS instance from outside check the followings:

  1. A inbound Security group rule to allow traffic from internet (0.0.0.0/0)
  2. Set Publicly accessible to Yes in 'Connectivity & security'
  3. Still if you are not able to connect then the RDS instance might be launched in one of the private subnets in the same AZ, as shown in console (also check the Subnet group).
  • If Subnet group have private subnets, make the private subnet as a public subnet i.e.; change the route table association of your private subnet with your public route table which is connected with your internet gateway.

Hope it helps!

Upvotes: 0

Dasith Rathnasinghe
Dasith Rathnasinghe

Reputation: 35

My problem was solved by setting public accessibility yes. https://aws.amazon.com/premiumsupport/knowledge-center/rds-connectivity-instance-subnet-vpc/

Upvotes: 0

AnkitsIaaC
AnkitsIaaC

Reputation: 33

I faced the same issue, turns out that I had made the database private to the VPC, meaning only instances in the vpc would be allowed to access the databse, so either make the DB public or try to access the database using an instance in your VPC.

Upvotes: 0

Đo&#224;n Nghĩa
Đo&#224;n Nghĩa

Reputation: 126

I had the same problem. this solution: When you create database

in the Virtual private cloud (VPC), please choose "Create new VPC"

in the VPC security group, please choose "create new", don't choose "choose existing"

enter image description here

Upvotes: 4

waseber
waseber

Reputation: 241

Anyone encountering this issue today should check out this YouTube video at around 6:05:

AWS RDS MySQL Database Setup | Step by Step Tutorial.

In a nutshell, you have to create a new inbound security rule to allow an external connection.

Upvotes: 24

Hansa Tharuka
Hansa Tharuka

Reputation: 137

change settings to Publicly accessible. by clicking Modify option

Upvotes: -3

mootmoot
mootmoot

Reputation: 13166

You should diagnose connection to ANY Mysql/Mariadb/RDS connection before changing any server parameter.

Always use this to check connection.

mysql -u username -p  -h your_rds_instance_name

If connection fail, then check network connection(can you ping the instance name from your local system? ), i.e. firewall access, RDS Subnet rules, security groups rules. If the topics too advance for your, then follow the usual quickstart guidelines and tutorial.

Upvotes: 1

Craig van Tonder
Craig van Tonder

Reputation: 7677

"I tried commenting the #bind-address = localhost but no solution. "

No you cannot just comment it out.

If you want to allow remote connections to the MySQL database then you need to bind to your network adapter and not localhost / the loopback adapter.

So you need to get your server IP then:

bind-address = the.srv.ip.is

This is a better question for Server Fault ;)

Upvotes: 0

Related Questions