Simple creation of AWS RDS (relational database service) instance and connected
Tags: webdev, aws, community, database
Published: 2023-02-24 00:43:37

**What is Amazon Relational Database Service?**

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.

   
**Amazon RDS DB instances**

A DB instance is an isolated database environment running in the cloud. It is the basic building block of Amazon RDS. A DB instance can contain multiple user-create databases, and can be accessed using the same client tools and applications you might use to access a standalone database instance. DB instances are simple to create and modify with the AWS command line tools, Amazon RDS API operations, or the AWS Management Console.


**AWS RDS (relational database service) engine :**

Amazon Relational Database Service RDS is a managed relational database service that provides you seven familiar database engines to choose from, including :

1- Amazon Aurora MySQL
2- Amazon Aurora PostgreSQL
3- MySQL
4- MariaDB
5- PostgreSQL
6- Oracle
7- Microsoft SQL Server

**Amazon RDS storage types**

Amazon RDS provides three storage types:

• General Purpose SSD (also known as gp2 and gp3).
• Provisioned IOPS SSD (also known as io1).
• magnetic (also known as standard).

They differ in performance characteristics and price, which means that you can tailor your storage performance and cost to the needs of your database workload. You can create MySQL, MariaDB, Oracle, and PostgreSQL RDS DB instances with up to 64 tebibytes (TiB) of storage. You can create SQL Server RDS DB instances with up to 16 TiB of storage. For this amount of storage, use the Provisioned IOPS SSD and General Purpose SSD storage types.

**Creation of Relational Database Service RDS**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e2dgknvd55szh1azbx5k.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ecapct8zfe7o8h59ssn.png)


• Select the version of the engine - in this practice we will connect to the version 8.0.25
**In Templates:**
• choose a sample templates to meet your use case
Here we choose the free tier template.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvw6pb5m1pyayolecf6k.png)

**In settings:**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mh01i2j3w94p9gsry8x.png)

**In instance configuration:**
• Choose the database instance class that meet your processing power and memory requirement, here we have option of Burstable classes that include t classes (all other are disabled for us because we have selected free tire option).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8p1m9sixpsqyvfeyfyck.png)
**Note:** if we have choose another template, the additional DB instance classes will be able to be usage.

**In storage:**
• Choose the type of storage
• Allocate a size for storage, the minimum value and maximum value for storage depend on the type of storage.
• You can enable storage autoscaling by select the checkbox.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jxnbn2321uldf18bq7i.png)

**In connectivity:**
• You can choose whether to set up to a connection to a compute resource for the database will be manually or automatically .
• For the virtual private cloud (VPC), we will choose a VPC or use the default VPC and subnet group.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdqk7ay8ef01fxv6xxsy.png)

**In public access:**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yh4gv83s4s44ydm0rzlh.png)

**In additional configuration:** the port of the database is 3306.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hyf5pn0crk3jgvm10w8.png)

**For the DB authentication:** choose the option you use to be authentication your DB.
Here we use the password authentication to use username and password to log in to DB.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yandoyg4h8ygo5jqneg7.png)

**In additional configuration:**
• You can choose make a backup, maintenance, ClodWatch logs, delete protection by click on the checkbox for any services.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iw5lp7gsshrswhq48wjr.png)

The creation of database is being starting.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2byt4bj15bv26ube8i0c.png)
And after a few of minutes our database is successfully creation.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1x2j9474hy7clssmbs6.png)

To open our database details, click on the database name to open it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gbpf6my43t1tgnfmdso.png)


**Connect to the database:**

After we have created our database, we now need to connect to our database to enter the data we need.
There are several ways to connect to the database:
• One way is to use Connect with MySQL Workbench.
• Or through by ec2 instance to connect to the database.
In this practice, we will use an ec2 instance which is have the security group are all open inbound and outbound to connect to our database :
Connect to the previously created instance by selecting it and clicking **Connect**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cn360yp2tki2fjrblgxt.png)
Choose any method of connection to connect to the instance and click on **Connect**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d63wgt6s4to253npo3ch.png)

To connect to the database via EC2:
 - After connect to the ec2 instance : install MySQL client 8.0 on Ubuntu by the commend:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8jptrgwu1dqv39l2ydn.png)
The execution:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wq1va9bzyh1johvlw4po.png)


• After the installation is completely and the MySQL client has been install so the next step we will do is we will connect to our MySQL RDS instance.
To do the connection execute the following command:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbjx9xmh7t2qnnf1wfgk.png)

Then click enter:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57cah089e4cyx749b4wh.png)

• Enter the password of the database and click enter:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5afnpuazq1gaakn4seh0.png)
Now to create simple table of data let us execute some commands :
• To create database:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icue2vqdgai3c2irhquk.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3nrz1l9qhoo2rkd580p.png)
• To create table:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gytzmy40uiue4ixsu7o3.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ixiaqvvveijdepldotd.png)

• To insert data to the table:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/djdqit6zac99oukarg8q.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56utulkyzynxi7dky87b.png)

• To view the table:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i6a4khzd0fd1o23fj1mq.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ziakln5pdqbgtzczgun1.png)
• Insert another row (data) to the table:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u74k3rg5xhsmwrk63lti.png)
• To view a row :

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q358z8sjidzli68v6oog.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oiln2grp66r1b6cgrfyv.png)
• To exit from the database execute the command :
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rffh054f7lofgh4xv86d.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qitf6om5u7d8461cnvgl.png)




**References:**

[1]https://aws.amazon.com/rds/
[2]https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.html
[3]https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html