Create and connect to a mysql database on aws rds

Published on December 16, 2021
Last updated December 16, 2021

In this post we will be looking at how we can create a mysql database instance on aws rds and connect to it from local machine to do sql operations.

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides you with complete administrative and data management capabilities, without software or hardware to install. Amazon RDS provides you with the tools to launch and manage a MySQL or MariaDB database in the cloud.

The database engines provided by Amazon RDS include MySQL, MariaDB, PostgreSQL, amazon aurora, Microsoft sql server and Oracle.

This tutorial shows you how to create a MySQL database instance on Amazon RDS and connect to it from local machine to perform queries.

Create a mysql database on aws rds

Go to the AWS RDS console and click on the Create database button. create database on aws rds

In Standard create select mysql as database engine

select mysql as database engine

Change only the below mentioned fields and keep everything else as default.

In Templates section select free tier.

free tier template

Enter a password for the database be sure to make a note of your password as we will need it later to connect to the database.

enter password

It is better to disable storage autoscaling if just testing the database but if you need it then decrease the maximum storage size to prevent unexpected costs. storage auto scaling upper limit

In the connection section set the public access parameter to yes. enable public access

Keep all the remaining fields as default and select the Create database button at the bottom of the page to create the database.

Now you can see that your database is being created.

database being created

Get the endpoint of your aws rds database

After the database is created you can get the endpoint of your database to connect to the database.

To get the endpoint of your database go to the AWS RDS console and click on the databases tab

From the databases tab click on the database name you want the endpoint of.

select database

There in the connectiviy section you can see the endpoint and port number of your database.

endpoint info

Edit security rules to allow inbound traffic

Click on the security group in the Connectivity and Security section.

Go to inbound rules and click on the edit inbound rules button.

Edit inbound rules

Add rule to allow inbound traffic to your database.

Click on Add rule button.

Set Type as All traffic

Source as anywhere ipv4

Now click on Save rules button to save the changes.

save inbound rules

Connect to mysql database from local machine using mysql workbench

Open the mysql workbench and click on new connection mysql connections new connection

Enter the connection name of your choice

Enter the hostname of your database that is the database endpoint

Enter username that we set at the time of creating the database

There is a high chance of it being admin

Click on store in vault and enter your password that we set at the time of creating the database

MySql store password new connection

and click ok

MySql close password prompt new connection

Click on Test connection button to test the connection

MySql Test connection

If everything went fine you will see the following message

MySql connection ok

Click ok and close the prompts

You can now see the new database in the MySql Connections tab in the mysql workbench. mysql connections

click on it to perform sql operations.

MySql workbench performing sql queries

You have successfully connected to a aws rds mysql database from your local machine using mysql workbench and run sql queries on it.



Tags :