How to install MYSQL in AWS ec2 instance

What you will learn here MySQL database installation on AWS EC2 instance

  • How to install MySQL in AWS ec2 instance

In order to install the MYSQL database on AWS EC2 instance first, we need to AWS access EC2 instance using PuTTy. So please click on the following link to know how to access AWS EC2 instance using PuTTY.

How to access EC2 instance using puTTY

How to install MYSQL in AWS ec2 instance

Please follow the following steps to know how to install MYSQL in AWS ec2 instance.

1)Assuming you have successfully accessed AWS EC2 instance using the above link.

2)Please execute the following command to go in root mode which is shown below

sudo su
cd ../..

3)Execute the following command to update the existing packages.

sudo apt-get update

4)Now execute the following to install MySQL server which is shown below. While installing if it is asking do you want to continue then please enter y and hit enter

sudo apt-get install mysql-server

How to install MYSQL in AWS ec2 instance

5)Now please execute the following command for secure installation which is shown below.

sudo mysql_secure_installation

6)Please hit Enter for current root password.

7)Now please Enter y and hit Enter for setting a new password which is shown below

8)Now Please enter New password which is shown below

9)Now please enter y to remove anonymous user and hit Enter.

10)Now please enter y to disallow remote login which is shown below

11)Please enter y to remove test databases which is shown below

12)Please enter y to reload privileges tables which is shown below

13)Now please execute the following command to login into the database and Enter the password which you have entered in step 8.

sudo mysql -u root -p


14)Please execute the following command to see databases present in the MySQL database.

show databases;


15)Execute the following to create a Demo database in MySQL server which is shown below.

CREATE DATABASE Demo;


16)Now please execute the following to go in Demo database

USE Demo;

If you are getting any error for the following command then please replace all single quote with the single quote of your keyboard

17)Please execute the following command to create the database user

CREATE USER ‘admin’@’localhost’ IDENTIFIED BY ‘admin’;


18)Execute the following command to grant all privileges

GRANT ALL PRIVILEGES ON Demo.* TO ‘admin’@’localhost’;


19)Now execute the following command save all the changes

FLUSH PRIVILEGES;


20)Now please execute the following command to come out of the database.

quit


21)Execute the following command to restart the MYSQL server

sudo service mysql restart

You may also like...

Leave a Reply