Steps To Connect EC2 Instance To Amazon RDS

Steps To Connect EC2 Instance To Amazon RDS

ยท

2 min read

RDS :-

Amazon RDS (Relational Database Service) is a managed database service designed to simplify the setup, operation, and scaling of a relational database for use in applications. It offers cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching, and backups.

EC2 :-

Amazon EC2 (Elastic Compute Cloud) is a central part of Amazon.com's cloud computing platform, Amazon Web Services (AWS). It allows users to rent virtual computers on which they can run their own computer applications. EC2 provides scalable computing capacity in the AWS cloud, reducing the need for investments in physical hardware and helping you scale and manage computing resources according to your requirements.

Step 1 :-

In AWS , go to RDS and create a database. select engine options as mysql.

select free tier option as follows:-

After that create a username and password. In credentials management select self managed.

In Instance configuration choose :- db.t3.micro

select DB subnet group as default.

In database authentication choose password authentication as we have created password.

and click on create databse. after clicking on create databse it will take some time.

The databse is created.

Step 2:-

create an ec2 instance. after creating ec2 instance connect to that instnace using ssh or ec2 connect.

after connecting use these commands to install mysql client.

sudo apt-get update

sudo apt-get install mysql-client

To setup connection between RDS and EC2 click on set up EC2 connection.

select EC2 from dropdown in which you have installed mysql-client.

click on continue and set up the connection.

use mysql -u admin -h (url of rds) -p (password) which we have created in databse authentication to connect with RDS databse. If This command doesn't work then create an IAM role to connect EC2 to RDS and select policies as AmazonRDSFullAccess attach this policy and create role and try running the above command.

you are now able to connect mysql. use below commands to create database.

use show databses;

command to see all databases.

To delete the database go to actions and delete the databse.

"Thank You!" For reading the article. I hope you liked it ๐Ÿ˜Š.

Did you find this article valuable?

Support Aakanksha Deshmukh by becoming a sponsor. Any amount is appreciated!

ย