...

/

Migrate the WordPress Database to AWS RDS

Migrate the WordPress Database to AWS RDS

Learn to back up the WordPress database to migrate it to AWS RDS.

In this chapter, we’ll migrate the MariaDB database, which is currently hosted on the same EC2 instance as WordPress, to an external RDS MariaDB database.

Doing so allows us to separate the components of the WordPress application and scale them individually. By using RDS, we gain access to all of the options AWS provides to scale and operate databases efficiently.

Migration steps

Let’s take a look at the steps involved to migrate the database.

Step 1: Launch WordPress instance from launch template

The first step is to recreate the WordPress instance. To do so, we can use the new launch template.

Execute the following command in the terminal:

Press + to interact
aws ec2 run-instances \
--launch-template 'LaunchTemplateName=custom-wordpress-vpc' \
--query 'Instances[*].{InstanceId:InstanceId,PublicIpAddress:PublicIpAddress}' \
--output text

The command starts a new instance based on the launch template with the name custom-wordpress-vpc.

  • The --query parameter filters the output to only display the InstanceId and the PublicIpAddress. We’ll use PublicIpAddress to connect to the WordPress instance via SSH.
  • --output text formats the output as text.

Run the command above. The output should look similar to this:

Press + to interact
i-0882be6b7fabebe05 None

Now, it seems that instead of a PublicIpAddress, we got None. This can happen because the public IP address will only be assigned once the instance is ready.

Therefore, let’s wait a bit and run the following command after a few minutes:

Press + to interact
aws ec2 describe-instances \
--filters "Name=tag:team,Values=wordpress" \
--query "Reservations[*].Instances[*].PublicIpAddress" \
--output=text

We’re using the describe-instances command with the --filters parameter and only select instances that ...

Access this course and 1400+ top-rated courses and projects.