Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating existing database to Amazon RDS

How can I import existing MySQL database into Amazon RDS?

like image 259
vishnu Avatar asked Jan 24 '11 11:01

vishnu


People also ask

Can your existing database be migrated to AWS?

Discover, assess, convert, and migrate your database and analytics workloads to AWS with automated migration. Maintain high availability and minimal downtime during the migration process with Multi-AZ and ongoing data replication and monitoring.

Does Amazon RDS support data replication of existing databases?

Amazon RDS doesn't support circular replication. You can't configure a DB instance to serve as a replication source for an existing DB instance. You can only create a new read replica from an existing DB instance.


2 Answers

Simplest example:

# export local db to sql file:
mysqldump -uroot -p —-databases qwe_db > qwe_db.sql

# Now you can edit qwe_db.sql file and change db name at top if you want

# import sql file to AWS RDS:
mysql --host=proddb.cfrnxxxxxxx.eu-central-1.rds.amazonaws.com --port=3306 --user=someuser -p qwe_db < qwe_db.sql
like image 109
Lev Lukomsky Avatar answered Sep 25 '22 02:09

Lev Lukomsky


I found this page on the AWS docs which explains how to use mysqldump and pipe it into an RDS instance.

Here's their example code (use in command line/shell/ssh): mysqldump acme | mysql --host=hostname --user=username --password acme

where acme is the database you're migrating over, and hostname/username are those from your RDS instance.

You can connect to RDS as if it were a regular mysql server, just make sure to add your EC2 IPs to your security groups per this forum posting.

I had to include the password for the local mysqldump, so my command ended up looking more like this: mysqldump --password=local_mysql_pass acme | mysql --host=hostname --user=username --password acme

FWIW, I just completed moving my databases over. I used this reference for mysql commands like creating users and granting permissions.

Hope this helps!

like image 42
Alex W Avatar answered Sep 27 '22 02:09

Alex W