Hosting Your Own WordPress Blog – Step 5 – Create MySQL Cloud Database Using Amazon RDS

Step 5 – EASY

Amazon makes it really easy to create a cloud database, but once again: the control interface may not be easy to understand. In this step, we will create an Amazon RDS cloud database, jot down important information about how to connect to it, then use the MySQL Workbench application to confirm our connection succeeds. Once we connect via the Workbench, connecting our blog software the same way should be very easy.

MySQL Workbench Logo
MySQL Workbench Logo

First, Download & Install the MySQL Workbench application. As stated, we will use this application to connect to the RDS Database we create later, but we won’t use it for much else. This is an important method of “sanity checking” our RDS database connection, and prevents us from going crazy when we try to install WordPress later. https://dev.mysql.com/downloads/workbench/

 

AWS Management Console Login
AWS Management Console Login

Second, log into your Amazon AWS console. You’ve already done this in earlier steps, so you’re possibly still logged in now. The AWS console is located here:  AWS Management Console.

 

 

 

 

 

Third, locate the RDS option from the AWS Services list. If you can’t find it, type “RDS” into the search bar provided and hit enter. This will take you to the RDS home page.

AWS services - Search for RDS
AWS services – Search for RDS

 

Fourth, click the “Create Database” button. This button can be found on the RDS dashboard, and within the instances list. From the “Select Engine” page, choose the “MySQL” option and click Next:

Amazon RDS - Select Engine
Amazon RDS – Select Engine

On the “Choose Use Case” screen, click on the Production – MySQL option and click Next. Other options would also work, but we will go with the production option for this tutorial.

Amazon RDS - Choose use case
Amazon RDS – Choose use case

On the “Specify DB Details” screen, we’ll choose the following options:

  • : MySQL Community Edition
  • License model: general-public-license
  • DB engine version: MySQL 5.6.40 (but you should choose whichever is the latest version. 5.6.40 was the most recent version at time of writing.
  • DB instance class: db.t2.micro – 1 vCPU, 1GiB RAM. For our purposes, we’re keeping the size of our instance as small as possible. But this is really a decision you’ll need to make for your own blog. Do you anticipate a lot of traffic immediately? Do you expect things to be a bit slow at first while you build content and gain a following? Regardless of what you choose, you’ll be paying for it monthly, so choose whichever works for you.
  • Multi-AZ deployment: No. I always choose Create replica in different zone because I like the idea of high availability, but it’s not needed unless you expect a lot of traffic immediately. Basically, your data is made available in multiple locations, taking the load off the central location, and allowing your database to work fast.
  • Storage type: General Purpose (SSD)
  • Allocated storage: 20 GiB

With the above settings, the cost per month is estimated and displayed. As you can see, our cost per month is quite low, coming in at $14.71. Feel free to play with the settings above and find the price that works best for you. Note that some things such as Milti-AZ deployments will double your cost immediately.

Amazon RDS - Instance Cost Estimate
Amazon RDS – Instance Cost Estimate

Next, we create our connection info. This part is super important, as it will define how our MySQL Workbench application will connect to our database for sanity checking, and how our blog software will connect during the installation phase. I generally name my instance identifier similar to my EC2 names, with “prod” or “test” somewhere in the mix. Master user name is for the user that has “god level” permissions on the database. Meaning, this user will have the power to create other users, destroy information, run dangerous commands, etc. Finally, create a strong password and click Next. Be sure you don’t forget any of this information, or you’ll need to delete your database and start over!

Amazon RDS - Instance Settings
Amazon RDS – Instance Settings

Next is the “Configure advanced settings” page. Most options on this page can be kept as-is. But there are a couple to mention:

  • Under Database Options, be sure to add a database name. I recommend something similar to the instance name, such as: sample_prod_database.
  • For Port, be sure the value is 3306. If it isn’t, or you wish to change it, be sure to write the new value down in your notes.

Once complete, press the Create database button. This will take a while, as illustrated by the following status on the “instance” page. You’ll have to be patient while this completes. Until then, we will not be able to continue with the sanity checking step below. If you observe this status, you may see it change from “creating” to “modifying”, “backing-up”, then “available”.

Amazon RDS - Creating
Amazon RDS – Creating

Fifth, we sanity check our RDS connection. We will use MySQL Workbench and our connection info for this. To start with, launch the MySQL Workbench application. You should see a home screen similar to mine, minus the “localhost:3306” connection:

MySQL Workbench - Home Screen
MySQL Workbench – Home Screen

From this screen, click the little “+” icon at the top. We will use this dialog to create a  connection to our RDS instance, similar to below. Please make the following entries then click Ok.

  • Connection Name: sampleprod
    Give the connection any name here, but I suggest that you use your RDS instance name you created earlier. This will help you identify and connect to the proper instances, and help you avoid mistakes.
  • Hostname: sampleprod.cdjamybnca2v.us-west-2.rds.amazonaws.com.
    You’re probably wondering where I got this value from? Visit your Amazon RDS instances page, click on your instance name, then scroll down to the “Connect” summary. In this summary, you’ll see an “Endpoint” value. I’ve copied a screenshot below.
  • Port: 3306
    This field will default to 3306, so you probably won’t need to change anything. But if you’ve decided on a different port when creating your RDS instance earlier, you’ll need to place that value here. Alternately, you can see “port” listed in your instance’s “Connect” summary below.
  • Username: hostingtutorial
    This is the master username created earlier.
  • Password: click the “Store in Keychain …” button and enter the password you chose during the Create Database steps. Note that MySQL Workbench doesn’t want to store your password directly, so they’re using your system’s “Keychain”, since this is generally more secure.
MySQL Workbench - Setup New Connection
MySQL Workbench – Setup New Connection
Amazon RDS - Instance Connection Endpoint
Amazon RDS – Instance Connection Endpoint

 

After pressing OK, a connection will be added to the MySQL Workbench home screen. Double click on that connection icon and a new tab will open. If you’ve connected successfully you’ll see a list of Schemas on the left (innodb, sample_prod_database, sys). If you’re having trouble, you can close that tab, go back to the home screen, right click on your connection icon, and choose “Edit Connection”. From the edit dialog, you can make changes and click “Test Connection”.

MySQL Workbench - Connection Icon
MySQL Workbench – Connection Icon
MySQL Workbench - Connected in new tab
MySQL Workbench – Connected in new tab
MySQL Workbench - Test Connection in Connection Editor
MySQL Workbench – Test Connection in Connection Editor

 

Finally, we edit our RDS instance security rules. Much like our EC2 instance, our new RDS instance has a lot of security applied by default. This is a great thing, but means we need to update our security rules to allow our WordPress blog the ability to connect to the RDS database on our behalf.

From the RDS instance control panel, scroll down to the “Connect” section and find the security group links. Click on the “rds-launch-wizard” link to open the editor:

Amazon RDS - Instance Security Group
Amazon RDS – Instance Security Group Link

From the editor, click the “Inbound” tab and click the “Edit” button. This will spawn the following “Edit inbound rules” dialog. You may notice that you already have an entry and “Source” is listed as “My IP”. Change this entry by selecting “Anywhere” as seen below, then click “Save”.

Amazon RDS - Inbound Rules Editor
Amazon RDS – Inbound Rules Editor

 

Congratulations!

You’ve completed step 5, which is ranked at EASY difficulty. Now onto step 6.

 


All Steps:

Introduction & Overview- Hosting Your Own WordPress Blog

  1. (EASY) Buying a Domain Name
  2. (HARD) Create a Cloud Server Using Amazon AWS
  3. (EASY) Create a Hosted Zone Using Amazon Route 53
  4. (HARD) Install Apache and PHP on Your Cloud Server
  5. (EASY) Create MySQL Cloud Database Using Amazon RDS
  6. (EASY) Download and Install WordPress on Your Server

Leave a Reply

Your email address will not be published. Required fields are marked *