Exercise: Create and connect to a MySQL DB instance with Amazon RDS

Natasha Ong
This is some text inside of a div block.
4 min read

Exercise overview:

In this exercise, you will learn how to create an environment to run your MySQL database (we call this environment an instance), connect to the database, and delete the database instance. We will do this using Amazon Relational Database Service (Amazon RDS).


By the end of this exercise, you should be able to do the following:

  • Create an environment to run your MySQL database
  • Connect to the database
  • Delete the database instance

Task 1: Create a MySQL DB Instance

In this task, you will use Amazon RDS to create a MySQL DB Instance with db.t2.micro DB instance class, 20 GB of storage, and automated backups enabled with a retention period of one day. As a reminder, all of this is Free Tier eligible.

  1. Open the AWS Management Console in a new browser window, so you can keep this step-by-step guide open. When the console opens, click on the nine dots on the top left, select Database from the left navigation pane, and choose RDS (second to last option) to open the Amazon RDS console.

2. In the top right corner of the Amazon RDS console, select the Region* in which you want to create the DB instance. In this exercise, choose N.Virginia.

AWS Cloud resources are housed in highly available data centre facilities in different areas of the world. Each Region contains multiple distinct locations called Availability Zones (which are data centres, or groups of data centres). Selecting a Region decides where you're hosting your Amazon RDS. More on Regions and Availability Zones later in the course!

3. In the Create database section, choose Create database.

4. In the Choose a database creation method section, choose Standard create

For now, you don't need to select Easy create - it's important to experience the manual, standard way (Standard create) first to truly build our fundamental understanding of databases!

5. You now have options to select your engine. For this exercise, choose the MySQL icon, leave the default value of edition and engine version, and select the Free Tier template. Ignore the Availability and durability panel.

Why is the Availability and durability panel greyed out? We would have to pay for Multi-AZ deployment. Using a Multi-AZ deployment will automatically provision and maintain a synchronous standby replica in a different Availability Zone (which is great for high availability). For more information, see High Availability Deployment.

6. Now let's finish this Settings page. The list below shows the example settings you can use for this tutorial. An important key word to know if configuration, or configuring. You'l see this word pop up heaps, and it simply means the settings you use when you're setting up a new instance of a resource. So yes, what you're doing right now is configuration!


  • DB instance identifier: Type a name for the DB instance that is unique for your account in the Region that you selected. For this exercise, you will name it rds-mysql-NextWorkDemo.
  • Master username: Type a username that you will use to log in to your DB instance. For this exercise, you will use masterUsername as your Master username..
  • Master password: Type a password that contains 8 to 41 characters (excluding /,", and @) for your master user password.
  • Confirm password: Retype your password.

Instance specifications:

  • DB instance class: Select db.t2.micro — 1vCPU, 1 GiB RAM. This equates to 1 GB memory and 1 vCPU.
  • Storage type: Select General Purpose SSD (gp2).
  • Allocated storage: Select the default of 20 to allocate 20 GB of storage for your database. You can scale up to a maximum of 64 TB with Amazon RDS for MySQL.
  • Enable storage autoscaling: This option does not apply to this exercise. If your workload is cyclical or unpredictable, you would enable storage autoscaling to enable Amazon RDS to automatically scale up your storage when needed.

7. You are now in the Connectivity section where you can provide information that Amazon RDS needs to launch your MySQL DB instance:


  • Compute resource: Choose Don’t connect to an EC2 compute resource. You can manually set up a connection to a compute resource later.
  • Virtual Private Cloud (VPC): Select Default VPC.

Additional connectivity configurations

  • Subnet group: Choose the default subnet group.
  • Public accessibility: Choose Yes. This will allocate an IP address for your database instance so that you can directly connect to the database from your own device.
  • VPC security groups: Select Create new. This will create a security group that will allow connection from the IP address of the device that you are currently using to the database created.
  • Availability Zone: Choose No preference.
  • RDS Proxy: Leave the RDS Proxy unchecked. By using Amazon RDS Proxy, you can allow your applications to pool and share database connections to improve their ability to scale.
  • Port: Leave the default value of 3306. This is folded under the Additional configuration option

8. Amazon RDS supports several ways to authenticate database users. Choose Password authentication from the list of options.


  • Enhanced monitoring: Leave Enable enhanced monitoring unchecked to stay within the Free Tier. Enabling enhanced monitoring will give you metrics in real-time for the operating system (OS) that your DB instance runs on.

Under Additional configurations, you'll also see a section called Database options:

  • Database name: Enter a database name that is 1 to 64 alphanumeric characters. For example, "dbMainForMusic". If you do not provide a name, Amazon RDS will not automatically create a database on the DB instance you are creating.
  • DB parameter group: Leave the default value. A DB Parameter Group in AWS is a collection of settings for your database. It lets you tweak how your database works without changing each one separately, making management easier.
  • Option group: Leave the default value. Amazon RDS uses option groups to enable and configure additional features.

Next is the Backup section:

  • Backup retention period: You can choose the number of days to retain the backup you take. For this tutorial, set this value to 1 day.
  • Backup window: Use the default of No preference.

Next is the Maintenance section

  • Auto minor version upgrade: Select Enable auto minor version upgrade to receive automatic updates when they become available.
  • Maintenance Window: Select No preference.

Deletion protection: Turn off Enable deletion protection for this tutorial. When this option is enabled, you're prevented from accidentally deleting the database.

9. You will see at the bottom an 'Estimated Monthly costs section' but this will be free for us (under the free-tier subscription). Choose Create Database.

Your DB instance is now being created!! 

It could take several minutes for the new DB instance to become available - time for a leg stretch!

When it's ready, the new DB instance appears in the list of DB instances on the RDS console. The DB instance will have the status creating until the DB instance is created and ready for use. When the state changes to available, you can connect to a database on the DB instance.

Feel free to move on to the next step as you wait for the DB instance to become available.

Task 2: Download a SQL client

Once the database instance creation is complete and the status changes to available, you can connect to a database on the DB instance using any standard SQL client. In this task, you will download MySQL Workbench, which is a popular SQL client.

1. Go to the Download MySQL Workbench page to download and install MySQL Workbench. Before you start downloading the installer, make sure you select the correct Operating System (OS). If you are using Microsoft Windows choose Microsoft Windows, if you are using Apple MAC choose macOS from the drop-down. Note that if you're using a Macbook that does not use a M1/M2 chip, choose the second option (x86).

Note: Remember to run MySQL Workbench from the same device from which you created the DB instance. The security group your database is placed in is configured to allow connection only from the device from which you created the DB instance.

2. You will be prompted to log in, sign up, or begin your download. Choose No thanks, just start my download at the bottom for a quick download.

Task 3: Connect to the MySQL database

In this task, you will connect to the database that you created using MySQL Workbench.

1. Launch the MySQL Workbench application and go to Database > Connect to Database (On the keyboard, this is Ctrl+U/Cmd+U) from the menu bar.

2. Oo, a dialog box appears. Enter the following:

  • Hostname and Port: To find your hostname, flick back to your AWS account and click on the database once it's been created. You can find your hostname on the Amazon RDS console like this:
  • Username: Type in the username you created for the Amazon RDS database. In this exercise, it is 'masterUsername'
  • Password: Choose Store in Vault (or Store in Keychain on MacOS) and enter the password that you used when creating the Amazon RDS database (Step 6a in Task 1).

3. Choose OK. If you encounter an error (images for Windows and Mac below), you will have to modify the security group of the DB instance. You'll become quite familiar with security groups later in the course. For now, think of them as your database's private security guards that want to stop any unwanted traffic coming in.

4. To modify the security group of the DB instance, flick back to your AWS Console page where you're looking at the details of your database. Under the Connectivity & security tab, click the link to the security group.

5. You will be redirected to the Security Groups page with a filter of your DB instance security group. On the Inbound rules tab, choose Edit Inbound rules.

6. Choose Add rule:

  • Type: MYSQL/Aurora
  • Source/Source type*: Anywhere IPv4

7. Choose Add rule again:

  • Type: MYSQL/Aurora
  • Source*: Anywhere IPv6
    *Are you doing this exercise on a smaller window instead of full screen? The Source dropdown changes its name to Source type for smaller windows.

8. Click Save rules.

9. Try to connect again to your DB instance (refer to step 2a on this task. Don't forget to use the nine dots on the top left hand corner to navigate to RDS again, and select Databases from the left hand panel)

You will see a successful connection to your DB instance!!! Amazing work, you did it. Give yourself a shoulder pat. 😌🍀

Task 4: Delete the DB instance

You can easily delete the MySQL DB instance from the Amazon RDS console. It is a best practice to delete instances that you are no longer using so that you don’t keep getting charged for them.

1. Go back to the Amazon RDS console. Select Databases, choose the instance that you want to delete by clicking on the little circle next to your database's name, and then select Delete from the Actions dropdown menu.

2. You are asked to create a final snapshot and to confirm the deletion. For our example, do not create a final snapshot, acknowledge that you want to delete the instance (by typing in delete me in the text box at the bottom), and then choose Delete.

Congratulations! You have successfully done the following:

  • Created an environment to run your MySQL database
  • Connected to the database
  • Deleted the database instance

You should be very proud of yourself - this exercise was a pretty big step up from the previous ones, and you've made it. WOHOOO!