In this module, you will create a MySQL database for your WordPress site. Before you create your database, let’s learn why WordPress needs a MySQL database and why Amazon RDS is a good choice for your database needs.

Time to Complete Module: 5 Minutes

 

WordPress is a flexible content management system for building blogs, e-commerce sites, discussion boards, and more. For whatever kind of website you’re making, you will have content to store. In a blog, this will be your blog posts and comments. In an e-commerce site, it will be your products and user accounts.

This content needs to be permanently stored somewhere. WordPress uses MySQL to store this content. A lot of the data in a WordPress application is hierarchical, structured data. For example, your application may have blog posts which have user-submitted comments. A relational database is a good choice for storing hierarchical data like this. Further, MySQL is the most popular open source database, and it is a reliable, performant choice for this application.

Many installation guides for WordPress use a MySQL database that is on the same server as the WordPress installation. While this may be sufficient to start, there are a number of reasons you may not want your MySQL database on the same server as your WordPress installation:

● MySQL and WordPress will be competing for compute resources on the same server, potentially hurting your site’s performance.

● You are unable to horizontally scale WordPress by adding additional WordPress servers as your site becomes more popular.

● You are responsible for all database maintenance tasks, including database backups and security upgrades.

By using Amazon RDS for MySQL, these concerns go away. Your database will be on a separate instance than your WordPress installation, so they won’t be competing for resources. Further, you can create multiple WordPress installations that connect to a single MySQL instance on RDS, allowing you to scale your site horizontally. Finally, Amazon RDS for MySQL has automated backups and security patches to help you with your database administration.

In the steps below, you will launch a MySQL database using the AWS management console.


  • Step 1. Create your MySQL database

    To begin, go to Amazon RDS in the AWS console. Click the orange Create database button to get started.

    Module 1-step1a

    (Click to enlarge)

    Module 1-step1a

    The first step is to choose the database engine you want to use. Amazon RDS supports six different engines, from popular open-source options like MySQL and PostgreSQL, to commercial options like Oracle and Microsoft SQL Server, to a cloud-native option called Amazon Aurora that was custom-built to take advantage of the cloud.

    WordPress uses MySQL, so select that engine now.

    Module1-step1b

    (Click to enlarge)

    Module1-step1b

    In the Templates section of the creation wizard, there is an option to only show options that are available in the AWS Free Tier. Select this option now if you would like to use this lab for learning without spending any money.

    In a production setup, you may want to use features of Amazon RDS that are outside the free tier. These include:

    ● A larger database instance class, for improved performance;

    Multi-AZ deployments, for automatic failover and recovery in the event of an infrastructure issue;

    Provisioned IOPS for disk storage, for faster I/O performance.

    Module1-step1c

    (Click to enlarge)

    Module1-step1c

    Next, you will specify the authentication settings for your MySQL deployment. This includes the database name and the master username and password. 

    In the Settings section, enter wordpress as your DB instance identifier. Then specify the master username and password for your database. Choose a strong, secure password to help protect your database. Store the username and password for safekeeping as you will need it in a later module.

    Module1-step1d

    (Click to enlarge)

    Module1-step1d

    After setting your username and password, you can select key details about your MySQL deployment. This includes the instance class and storage details.

    The default settings will work for this lab. You will use a small instance class that is suitable for testing or small-scale applications, and it fits within the AWS Free Tier. If you don’t want to use the AWS Free Tier, you could set a larger instance class or alter the storage configuration options.

    Module1-step1e

    (Click to enlarge)

    Module1-step1e

    Next, you can configure connectivity and network configuration. Amazon RDS instances must be created in an Amazon VPC, which is a logically-separate network where your provisioned resources will live.

    VPCs are an advanced topic outside the scope of this lab. Fortunately, AWS has created a default VPC in each region in your account. The default VPC is already selected for you, and you can launch your RDS instance in this VPC.

    Finally, RDS provides a number of additional configuration options to customize your deployment. You need to make one change in this area. Click on the Additional configuration line to expand the options.

    Module1-step1f

    (Click to enlarge)

    Module1-step1f

    Set the initial database name to wordpress. This will ensure RDS creates the database in your MySQL instance upon initialization. You will use this database name when connecting to your database.

    Module1-step1g

    (Click to enlarge)

    Module1-step1g

    At the bottom of the creation wizard, AWS will show you estimated monthly costs for your RDS database. If you are still eligible for the Amazon RDS Free Tier, you will see a note that the database will be free to you for up to 12 months.

    Click the orange Create database button to create your database.

    Module1-step1h

    (Click to enlarge)

    Module1-step1h

    You should see a success notice indicating that your database is being created.

    Module 1-step1i

    (Click to enlarge)

    Module 1-step1i

    In this module, you created a fully-managed MySQL database using Amazon RDS. In the next module, you will create an Amazon EC2 instance for running your WordPress site.