INSTALLING EC2 INSTANCE AND ATTACHING TO MSQL DATABASE IN AWS​

INSTALLING EC2 INSTANCE AND ATTACHING TO MSQL DATABASE IN AWS​


 Amazon Linux 2 is a popular webserver operating system, we need to know how to install MySQL database server on Amazon Linux 2. At first, you create an EC2 instance in AWS.

I am assuming that everyone already created EC2 instance on AWS. Now you have to connect your instance via Putty or Terminal.


Install MySQL server on AWS Amazon Linux EC2

Now, I’ll show you how to install MySQL on your Amazon Linux 2 EC2 instance using the commands below. Let me go over each command one by one so you understand what you’re doing and, if you get stuck, you can look up the error message to find out what’s wrong.

Command:

sudo yum update -y

So sudo yum update -y basically updates all packages to the latest version from an Amazon-managed repository list for Amazon Linux 2. So now that we’ve updated our package list, the next command will be to install the MySQL server on this machine.

Command:

sudo yum install -y mariadb-server





After this, MySQL install command will ask you a few questions, After you’ve provided those answers, please run this command to start the MySQL server and enable it to run at boot time. If your server reboots, you must manually run the command to restart the MySQL server.

Start the mysql server

Enable mysql to start when system reboots

Now, we need to secure the installation by running below command.



It will ask you a few questions, whose answers are given in my video tutorial, but I am writing it here as well.

Question: Enter current password for root ( enter for none ) :

Answer: Just press enter because there is not root password available as we just did the setup now.

Question: Set Root password? [Y/n]

Answer: Type here ‘y’ and then press enter. Then it will ask you for new passwords. Please provide a strong password and press enter.

Question: Remove anonymous user? [Y/n]

Answer: type ‘y’ and press enter

Question: Disallow root login remotely? [Y/n]

Answer: type ‘y’ and press enter.

Question: Remove test database and access to it? [Y/n]

Answer: Type ‘y’ and press enter. This will remove the test database and its access to users. If you want to keep the test database then type ‘n’ and press enter. The choice is yours, but I suggest to delete the test database.

Question: Reload privilege tables now? [Y/n]

Answer: Type ‘y’ and press enter. This is reload the privilege tables.

If you have answered the last question, then it’s done and you have secured the MySQL installation.

After that, you can connect to your mysql server by running this command.

if you run this command then it will ask you for the password. Please enter the new password which you set in the MySQL secure installation process.




Create an Database DEMO:

Command :show Database;

Command: CREATE DATABASE Demo;

Command: USE Demo;





Command:CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';

Command:GRANT ALL PRIVILEGES ON Demo.* TO 'admin'@'localhost';





Command: FLUSH PRIVILEGES;

Command : quit;




Comments

Popular posts from this blog

VPC in AWS

S3 Replication