Migrating a WordPress Site to Amazon RDS

Overview

Given a typical Wordpress installation — i.e., with MySQL running on the local machine — this article will outline the steps to migrating the MySQL instance to Amazon RDS.

Procedure

1. Launch an RDS instance

2. Ensure security group rules on the RDS instance allow inbound traffic from the web server on the MySQL port (typically 3306).

3. Create a "backup" of the legacy database.

On the Linux instance
mysqldump --opt -u root -p database > database_YYYYMMDD_HHMM.sql

4. Determine the Apache root folder.

grep -i 'DocumentRoot' /etc/httpd/conf/httpd.conf

5. In the web root folder, edit the wp-config.php.

nano wp-config.php

6. Make note of the user and password for the database connection.

/** MySQL database username */
define('DB_USER', 'MyUser');

/** MySQL database password */
define('DB_PASSWORD', 'MySecurePassword');

7. Update the database hostname to match the new RDS endpoint.

/** MySQL hostname */
define('DB_HOST', 'My.Rds.Instance.us-east-1.rds.amazonaws.com');

8. Connect to the RDS instance as the administrative user and create a database for WordPress.

9. Run the MySQL dump file against the RDS instance.

10. Grant the application user remote access to the RDS instance.

Against the RDS instance.

grant select,insert,update,delete on *.* to 'MyUser'@'WebServerPrivateIpAddress' identified by 'MySecurePassword';