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.
- How do I import a local MySQL db to RDS db instance?
- Migrating existing database to Amazon RDS
- Importing Data from a MySQL or MariaDB DB to an Amazon RDS MySQL or MariaDB DB Instance
- Migrate On-Premises MySQL Data to Amazon RDS (and back)
3. Migration from RDB to local mysql database
Whereas on the other direction, relatively fewer pages seem to exist.
- "and back" above?
- Migrating Data to an External MySQL Instance from RDS
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:
- Make an EC2 instance to migrate to from the AMI.
- Make an AMI for backup and stamping.
- Migrate data on the new EC2 instance according to the following articles.
- For the wordpress and phpMyAdmin, change the connection setting to the local mysql-server.
- For the wordpress, edit the wp-config.php to change the DB_HOST setting to 'localhost'.
- For the phpMyAdmin, edit the config.inc.php to change the host setting to 'localhost'.
- Make an AMI of the new EC2 instance for backup
- Swap the EC2 instances.
- Terminate the old instances, i.e., EC2 and RDS instances.