How to Migrate MySQL RDS Instance from One AWS Account to Another

How to Migrate MySQL RDS Instance from One AWS Account to Another

In this tutorial I will show you, how to migrate MySQL RDS Instance from one AWS Account to another AWS Account.

Here 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 user@ubuntu2.example.com:

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.

Was this Tutorial helpful? Help others share on Facebook, Twitter, and Google Plus!

 

 
Enjoyed this video?
How to Migrate MySQL RDS Instance from One AWS Account to Another
"No Thanks. Please Close This Box!"