zeeshank1
zeeshank1

Reputation: 49

Unable to connect from local mysql server to AWS RDS db instance

I'm trying to import my .sql dump from local machine to AWS RDS db instance using the command:

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysqldump --host=localhost 
--user=root --password=admin e_learning_system | mysql 
--host=mydbinstance.cyz1k1vacvdd.us-east-1.rds.amazonaws.com 
--user=root --password=adminadmin e_learning_system

but it is throwing this error:

ERROR 2003 (HY000): Can't connect to MySQL server on 'mydbinstance.cyz1k1vacvdd.us-east-1.rds.amazonaws.com' (10060) mysqldump: Got errno 22 on write

How do I correct this?

Upvotes: 5

Views: 13999

Answers (5)

FourtyTwo
FourtyTwo

Reputation: 754

I was getting the same error and I solved it by adding mysql.exe... to the firewall of the machine I was connecting to.

Upvotes: 0

Michael
Michael

Reputation: 2187

In case there is anyone who is still looking for a solution like I was, I managed to get it done by setting the security group in my RDS instance. Just go to that security group, you will find the click in "Security and Network" section. After you are on that security group page, edit the inbound rule, change the source to 0.0.0.0/0 (meaning accept from all) temporarily, and then import your db dump. That should work. But keep in mind you might want to revert it back this setting on production.

Upvotes: 6

Smokey
Smokey

Reputation: 1897

I prefer using MySQL workbench. It's much more easier & user friendly than the command line way.

It provides a simple GUI.

MySQL workbench or SQL Yog.

These are the steps that I did.

1) Install MySQL Workbench.

2) In AWS console, there must be a security group for your RDS instance. Add an inbound rule to that group for allowing connections from your machine. It's simple. Add your IP-address.

3) Open MySQL workbench, Add a new connection.

4) Give the connection a name you prefer.

5) Choose connection method- Standard TCP/IP

6) Enter your RDS endpoint in the field of Hostname (mydbinstance.cyz1k1vacvdd.us-east-1.rds.amazonaws.com).

7) Port:3306

8) Username: master username (the one which which you created during the creation of your RDS instance) (root)

9)Password: master password (admin admin)

10) Click Test Connection to check your connection.

11) If connection is successful, click OK.

12) Open the connection.

13) you will see your database 'e_learning_system' there.

14) Now you can export your mysqldump file to this database. Go to-> Server. Click Data Import.

15) You can check whether the data has been migrated by simply opening a blank SQL file & typing in basic SQL commands like use database, select * from table;

Upvotes: 0

Akash5288
Akash5288

Reputation: 1935

Yes, Amazon Beanstalk application and RDS security groups must be same for connecting application to database instance..

Right click on database instance and add a new security group using by beanstalk application..

Upvotes: 5

Paul Ma
Paul Ma

Reputation: 615

error 2003 means no connection to mysql server. Check if you allowed the machine from where you connect to RDS in the RDS security group.

Upvotes: 0

Related Questions