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:
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.
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!
7. You are now in the Connectivity section where you can provide information that Amazon RDS needs to launch your MySQL DB instance:
Additional connectivity configurations
8. Amazon RDS supports several ways to authenticate database users. Choose Password authentication from the list of options.
Under Additional configurations, you'll also see a section called Database options:
Next is the Backup section:
Next is the Maintenance section:
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.
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.
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:
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:
7. Choose Add rule again:
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. 😌🍀
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:
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!