What is RDS Instance?
Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud.
Supported Engines by RDS:
Each DB instance runs a DB engine. Amazon RDS currently supports the MySQL, MariaDB, PostgreSQL, Oracle, and Microsoft SQL Server DB engines.
Create a MySQL DB Instance:
In this blog, We will see how to create an DB instance of MySQL Engine.
Open the AWS RDS Management Console,
We will create a database with the Below configurations:
Engine : MySQL
instance type : db.t2.micro (which is free-tier eligible)
20 GB of storage with automated backup with a retention period of 3 days.
In the top right corner, Choose the AWS region as per your requirement.
You should see the following screen:
Choose Create Database,
Now you have the option to choose the DB engine, In this blog we will create MySQL database.
Choose the database version , For now we will set it to default value.
We have three templates to create RDS instance as per the environment,
For this tutorials, We will go with Free-tier eligible.
In the Settings, Give a unique name to the DB instance for identification.
In the credentials settings, We are going to create a admin user for the database,
In DB instance size, In the previous section as we have chosen free-tier template, You can find only one instance type db.t2.micro with 1vCPU and 1 GB of RAM.
In Storage section, Allocate the storage as per your requirement,
If you want the RDS instance to automatically scale the storage based on the threshold set , you can use the storage auto-scaling feature.
Choose the VPC , Subnet group and Security Group where you want to launch the MySQL database .We are leaving everything to default for this tutorial.
It is always recommeneded to keep the RDS instance , Private. Hence we choose publicly Accessible to NO
Click Create Database.
Once the Database is created, Let’s go ahead and connect to the DB instance.
Login to DB Instance:
Now the MySQL database is ready, You can find the DB endpoint here,
Important Note: If you set the publicly Accessible to NO, You cannot connect to your DB instance directly.
We have to setup SSH TUNNELING , and connect to DB instance from the EC2 Instance.
I have posted a separate article on How to launch EC2 instance, Set up SSH tunneling and connect to any Private DB instance.
LAUNCH EC2 INSTANCE:
Assuming that you have SSH Tunnel setup in place,
SSH into EC2 Instance and connect to the DB instance using below command,
#mysql -uadmin -p -h testdbinstance.cqenbvyhffql.ap-southeast-1.rds.amazonaws.com
You should be able to login to the database instance.
Running some sample database commands:
mysql> create database fitdevops;
Query OK, 1 row affected (0.01 sec)
mysql> create user ‘fitdevops’@’%’ identified by ‘[email protected]’;
Query OK, 0 rows affected (0.00 sec)
mysql> grant select on fitdevops.* to ‘fitdevops’@’%’ identified by ‘[email protected]’;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Now that, We know how to create a DB instance, Setup SSH tunneling and connect to the DB instance.
Please do check out other articles.