Relational Database Service in AWS

Relational Database Service in AWS

Let's begin!!

What is Amazon RDS?

Amazon Relational Database Service (Amazon RDS) is a collection of managed services that makes it simple to set up, operate, and scale databases in the cloud.

Task

  1. Create a Free tier RDS instance of MySQL.

    Go to the RDS service in the AWS console, create a database and then select MySQL from the engine options.

    Select the free tier option and provide a name for the database instance identifier.

    Enter the master username & the master password here.

    We can adjust these storage details as per our needs and choose the default VPC.

    Public access is assumed to be granted and you can either select an existing security group or create a new one.

    MySQL port number is 3306 and it is seen here.

    Note: Make sure the initial database name should be given otherwise database won't be created.

    Click on "create database" and wait a few minutes for the new database to be created. Finally, it is done.

  2. Create an EC2 instance.

    Launch an EC2 instance and add the port number 3306 to the inbound security rules.

  3. Create an IAM role with RDS access.

    Now it's time to create an IAM role having RDS access & follow these steps:

    Here we get the IAM role ready.

  4. Assign the role to EC2 so that your EC2 Instance can connect with RDS.

    So, let's assign the previously prepared IAM role to the EC2 instance using the following method.

    After updating the IAM role, let us now connect to the RDS database in this way.

    Select the EC2 instance, go to actions & then click on 'Connect RDS database' under Networking.

    Select the instance, check for the database name which we created & Click on Connect.

  5. Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.

    Connecting the EC2 instance using a MySQL client:

    First, install mysql-client in your instance by using the command

     sudo apt update
     sudo apt install mysql-client -y
    

    Copy the "db-instance endpoint".

    Check the version of MySQL and then use the command

     $ mysql -h <paste here db-instance endpoint> -P 3306 -u admin -p
     where the options denotes
          'h' for host
          'P' for port of database
          'u' for master username
          'p' for master password
    

    Enter the password so that the EC2 instance will connect with the MySQL client successfully.

That's all guys, thanks for your valuable time.

Reference

Amazon RDS

video


Thanks for reading my articles.

Keep reading, learning and upskilling.

Peace out!!