Print Friendly

1. Needs of migrations between local mysql database and RDS

Using RDS has several merits over local mysql database, but it does impose an extra cost. So, you should wisely choose one of these. In cases you made a bad choice or circumstances changed,  it would be helpful to have concise notes available on migrations from one to the other and vice versa.

2. Migration from local mysql database to RDS

On migrations in this direction, there seem to exist may pages.

3. Migration from RDB to local mysql database

Whereas on the other direction, relatively fewer pages seem to exist.

The procedures described in the above pages utilize replication, to make it rather cumbersome for simple applications. So, it might often be more convenient to use just mysqldump as described below.

4. Actual steps of migration from RDB to local mysql database

See also CDP:Stampパターン for design pattern.

Actual steps are:

  1. Make an EC2 instance to migrate to from the AMI.
    1. [AWS] AMIからEC2インスタンスを作成する。
  2. Make an AMI for backup and stamping.
    1. [AWS] EC2インスタンスのAMIを作成する。
  3. Migrate data on the new EC2 instance according to the following articles.
    1. How to export database from Amazon RDS MySQL instance to local instance?
    2. Amazon LinuxにMySQLをセットアップする方法
    3. MySQLのデータベースをmysqldumpでバックアップ/復元する方法
  4. For the wordpress and phpMyAdmin, change the connection setting to the local mysql-server.
    1. For the wordpress, edit the wp-config.php to change the DB_HOST setting to 'localhost'.
    2. For the phpMyAdmin, edit the config.inc.php to change the host setting to 'localhost'.
  5. Test
  6. Make an AMI of the new EC2 instance for backup
  7. Swap the EC2 instances.
  8. Terminate the old instances, i.e., EC2 and RDS instances.