Hosting Database(Database Tier)- AWS(Amazon Web Services)- In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage.
Steps:-
- Open EC2 Intance on AWS
- Click on Security Groups, Click on Create Security Group
- Give Security group name, I’m giving databasetiersg, & Description Allow My sql
- Inbound rules, Type- MYSQL/Aurora, Protocol- TCP, Port range 3306, Source-Anywhere, 0.0.0./0, Description- Allow MySQL from anywhere
- Click on Create Security group, Security Group will be created
- Search rds(Managed Relational Database), Click on it
- Click on Create database
- Engine options->Select MySQL
- Engine Version- MySQL 5.7.40(My App Supports this, You Select Accoring to your app)
- Templetates- Free tier(I’m using free tier, you can use depending on your requirement)
- DB instance identifier- databasetierdb, Master username- root, Master Password- admin123, Confirm Password- admin123
- Instance Configuration- db-t3.micro(2 vCPUS, 1 GB RAM), this is enough for my app
- Allocated STORAGE- 20 GB, This is enough for my app
- Existing VPC security group- mydatabasetiersg(here im seclecting security group I created)
- Click on Create database
- Database will be created.
- Open Your App that you got on Github, This is my app
- Click on Code, Copy HTTPS Github link of your App, this is my App
- Connect To EC2 Instance Using Gitbash & Install Git Software on EC2 Instance Using Gitbash, To Install Type sudo yum install git
- Copy Link of your App on Github
- Type sudo git clone <Github App Link> /var/www/html & Press Enter, This Command is to clone App to Document root
- Type Clear & Press Enter, This Command is to clear screen
- Type ls /var/www/html, This command to check what is there in /var/www/html, our app files cloned to this location, we can see it
- Open AWS-> RDS->Databases->databasetierdb(database you created)
- Copy Endpoint
- Type yum -y install mysql php, we are installing mysql & php-mysql
- Type mysql -h <Endpoint> -u <DB Instance Identifier> -p
- Enter Password: admin123 (Database password)
- We are connected to RDS-MySQL Database(5.7.40)
- Type show databases; This is MySQL Command, it means show databases
- Type show tables; This command is to show tables in databases,It says no database selected
- Type use mysql; here we are selecting mysql database from the list of databases, Which means database changed to mysql now, we are on mysql database now
- Type show tables; This command show tables means it shows tables of mysql database, because we are on mysql database in databases, It has 40 rows
- Type desc user; desc means description, user means one table in database, we are seeing the description of the table called user. we can see 45 rows in user table
- Type Select user from user; In User table again we are selecting user with this command. we can see 4 rows in user.
- Type show databases; This command is to see databases. it again shows databases in mysql.
- Type Create database ibm; This command is to create database, ibm is the name of the database we are giving to new database, we are creating this database in mysql database
- Type show databases; we can see all the databases in the list along with ibm database we created.
- Now Open New Gitbash session, Connect with same EC2 Instance, Dont Close the previous Gitbash session.
- Type ls /var/www/html, To See the list in Document root /var/www/html
- You Can see Our App Files Here, health.html index ph.p Licence php README.md style.css
- Type sudo vi /var/www/html/php/db.php, we are creating Text file in php with the name db.php
- Text file is created, Press i, To Come into INSERT MODE(Edit Mode)
- On AWS->Databases-> Database we created-> Copy End point
- Paste End point at servername
- Replace user name & password with root & admin123, Note- this is my database instance name in aws, you write yours
- Press ESC & Type :wq, Press ESC Is to come out of Inset mode, :wq is to save & quit the file, db.php file will be saved on /var/www/html/php
- Type sudo systemctl restart httpd, to restart mysql server
- Copy Ipv4 address of EC2 Instance
- Open New tab Paste The Ipv4 address and Press Enter, You’ll see your app successfully Opened, This is my app Book Store
- On First Gitbash session Type use bookstore;
- Type show tables; to see tables in bookstore
- Type desc books; To see description of books table in bookstore
- Type select book_name from books; to see book name in books table, It shows Empty set, which means no books are there.
- Come to browser, Give a name of the book & name of author & price of it.I’m giving DevOps as book name, Sai as author name, 99 for the cost
- Type Select * from books; to see any books are there in books table, we can see the book name DevOps, author name Sai, Cost 99, which means the data is successfully saved.
- Give another book name, author, cost.I’m giving aws, sai,49
- I’m clicking on Blue color refresh button on the page, we can see number of books created and save with author names and cost of it.
- Come to AWS->RDS
- Click on Databases
- Select the database that you created, my database is dabasetierdb & Go to actions and select delete to delete the database.
- Unselect Create final snapshot, retain automated backups, because i dont the data anymore so im deleting it without creating snapshots or automated backups
- Select Acknowledge, and write delete me, click on delete
- The database i created for my app is deleted on RDS, i will not be charged anymore.
- Also I’m going to EC2 Instance that is created, selecting it & Terminate it, I Terminated the instance, i will not be changed for Ec2 anymore.
if you have any doubts, comment below
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://accounts.binance.com/ro/register?ref=FIHEGIZ8
It appears to own evaluated exactly what people are searching
for within an online gaming expertise and drawn every one of the halts to supply the product.
If you’re enjoying on the beginning position, you may want to play larger cards
and crease around the smaller people.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me. https://accounts.binance.com/en/register-person?ref=P9L9FQKY
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me. https://www.binance.info/join?ref=V2H9AFPY