Lab 5
Aim: RDS (Relational Database Service)
We can create databases in the cloud.
We can create 40 database instances per region.
This is under Database category.
Requirements:
1. Launch an EC2 instance using ubuntu AMI in default – VPC within subnet-1(US-EAST-
1A)
2. Create a database using RDS Service in default -VPC within subnet-1(US-EAST-1A)
3. Connect the database from the server
4. Execute MYSQL queries to create tables, databases, data insertion etc.;
Server and database should be in same subnet so it is easy for us.
1
Lab 5
Step 1:
Choose a database creation method
Standard create: You set all of the configuration options, including ones for availability,
security, backups, and maintenance. (customized database creation)
Easy create: Use recommended best-practice configurations. Some configuration options can
be changed after the database is created.
Step 2:
Engine options
Engine type:
1. Aurora (MySQL Compatible)
2. Aurora (PostgreSQL Compatible)
MySQL
3. PostgreSQL
4. MariaDB
5. Oracle
6. Microsoft SQL Server
7. IBM Db2
Step 3:
Templates
Choose a sample template to meet your use case.
Production: Use defaults for high availability and fast, consistent performance.
Dev/Test: This instance is intended for development use outside of a production
environment.
Free tier: Use RDS Free Tier to develop new applications, test existing applications, or
gain hands-on experience with Amazon RDS.
2
Lab 5
Due to less configuration we get less billing, we use free tier.
Username: admin
Password: banupswd-24
Min 20gb max 6,144 range of database
3
Lab 5
As we have chosen free tier, there is no additional storage we need to create that.
Select do not connect to an EC2 we will do that later.
4
Lab 5
sudo mysql -u admin -h studentdb.clzylxbutn3x.us-east-1.rds.amazonaws.com
syntax: sudo mysql -u username -h endpoint.
Commands for connecting database:
1. sudo su –
2. apt-get update
3. sudo mysql -u admin -h studentdb.clzylxbutn3x.us-east-1.rds.amazonaws.com
4. apt-get install mysql-server -y
5. apt-get install mysql-client -y
3.sudo mysql -u admin -h studentdb.clzylxbutn3x.us-east-1.rds.amazonaws.com
Alternately open EC2 service in another tab, then open instances select your required
instance then connect it simply.
As we didn’t have mysql we observe error when we execute 3, command, so that execute 4
and 5 then 3, command.
5
Lab 5
6
Lab 5
7
Lab 5
After connecting to database
Navigate into mysql using above commands then, you can observe as above image.
Create a database: CREATE DATABASE DB_NAME;
Display all databases: SHOW DATABASES;
Move into specify database: USE DB_NAME;
To create a table: CREATE TABLE TAB_NAME (COL1 DATATYPE, COL2 DATATYPE);
Display all tables: SHOW TABLES;
Order: SELECT * FROM TAB_NAME ORDER BY COL1;
8
Lab 5
Lab 5 is successfully completed