Hello everyone! Let's learn about Amazon Relational Database Services (RDS). An amazing product that lets you set up, scale and operate a relational database in the cloud. In this step-by-step tutorial, we will take a look at how to set up a MySQL connection in an RDS database.
- Understanding of relational databases. To learn more, read this article
- An AWS account. If you don't have one, sign up here
- MySQL Workbench installed in your machine. If not, install here
Step 1: Create Database in AWS RDS
Sign in and go to console.aws.amazon.com/rds. On the left-hand panel, make sure you are on Dashboard, then click Create Database.
Choose Standard Create option and the database you want to integrate with. I'll choose MySQL for this tutorial.
Choose the MySQL version you want to use, then select Free Tier. The other options would incur costs.
Next, name your DB instance. It can be anything you want, then proceed to create a username and password for it.
Leave the rest of the settings below as it is.
Scroll down to the Connectivity section. Set Public access to Yes and select Choose Existing for our Virtual Private Cloud (VPC). This will set it to the default.
Under Database Authentication, select Password Authentication, and you're done. Click Create Database at the bottom of the page to continue.
Step 2: Edit Inbound Rules
Our database is now all set up! Let's make sure we can access it from our local MySQL Workbench by editing the inbound rules. To do that, head to your RDS Console and navigate to Databases on the left panel.
Then, under Security Group Rules click on the Security Group that has the Type column as Inbound.
After clicking it, a new tab will open to the Security Groups page. Click on the Security Group ID.
And now, you can edit the Source to Custom or MyIP, whichever one you want to specify. For my example, I'm setting it to Custom, at IP 0.0.0.0/0. This means that this RDS Database can be accessed from any IP. Click Save Rules and close the tab.
Step 3: Set Up Workbench
All we need to do now is to create a new connection on MySQL Workbench.
If you haven't already, install MySQL Workbench.
Then, set up a new connection by clicking on the ⊕ icon as shown in the screenshot below.
Fill in your username and password according to the RDS Database you've just created.
Enter the hostname and port number according to the values from your RDS Console under Databases > Connectivity & Security.
Once that's done, you can click on the Test Connection button to see if it can connect to the RDS Database successfully. Click OK once successful.
We have just performed the necessary steps we need to deploy a MySQL database instance on the cloud with AWS RDS. Now we can integrate it with an app and operate it just like any other database.
To learn how to build a Node.js CRUD app with MySQL integration, feel free to read my beginner-friendly series.
Thanks for reading! I hope it has been a helpful introduction to AWS RDS. If you find this article helpful, be sure to like and share it around for more reach. To learn more about RDS and its amazing features, please check out the References section below. Cheers!