Migrate MySQL RDS Instance from One AWS Account to Another

We need to migrate a MySQL v5.6 RDS instance from one AWS account to another AWS account. 

Before We Begin

Both the current and the new MySQL RDS instances are hosted in the same region eu-west-1.

Neither the current nor the new MySQL RDS instances are publicly accessible.

MySQL database name is my_db and the size is around 5GB.

RDS endpoints in this case are:

  1. mysql1.cpamnz.eu-west-1.rds.amazonaws.com (current account)
  2. mysql2.kvpzln.eu-west-1.rds.amazonaws.com (new account)

On the New AWS Account

Launch an EC2 Linux instance. We use Ubuntu in this example.

You need to have a mysql-client installed:

# apt-get install mysql-client

Connect to the new MySQL RDS instance and create an empty database:

$ mysql -h mysql2.kvpzln.eu-west-1.rds.amazonaws.com -uadmin -p
Enter password:
mysql> CREATE DATABASE my_db;
mysql> exit;

On the Current AWS Account

Launch an EC2 Linux instance. We use Ubuntu in this example.

You need to have a mysql-client installed for mysqldump:

# apt-get install mysql-client

Dump the MySQL RDS database:

$ mysqldump -h mysql1.cpamnz.eu-west-1.rds.amazonaws.com -uadmin -p my_db | gzip > ./my_db.sql.gz

Copy the RDS database backup to the Ubuntu instance on the new account:

$ scp -i ./key.pem ./my_db.sql.gz [email protected]:

You can also create an AMI of the existing Ubuntu instance containing the database backup, and import the AMI to the new AWS account.

SSH into the Ubuntu instance on the new account, find the backup file, and unzip it:

$ gunzip my_db.sql.gz

Import the MySQL backup to the new RDS instance:

$ mysql -h mysql2.kvpzln.eu-west-1.rds.amazonaws.com -uadmin -p my_db < ./my_db.sql

That should be it.

4 thoughts on “Migrate MySQL RDS Instance from One AWS Account to Another

  1. What if I have multiple databases on single RDS instance?
    Do I have to perform these steps for each database separately?

  2. Amazon finally made this a lot easier. You can share RDS snapshots directly with another account now.

    Check it out: dataasapet.com/2016/03/09/how-to-share-an-encrypted-rds-snapshot-with-another-aws-account

Leave a Reply to Amol Chakane Cancel reply

Your email address will not be published. Required fields are marked *