MY-SQL Command

MY-SQL  Command

Commands used to host MySql Server on AWS EC2 Instance

Step 1: Update the system

sudo apt update

Step 2: Install MySql

sudo apt install mysql-server

Step 3: Check the Status of MySql (Active or Inactive)

sudo systemctl status mysql

Step 4: Login to MySql as a root

sudo mysql

Step 5: Update the password for the MySql Server

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'place-your-password-here';

FLUSH PRIVILEGES;

Step 6: Test the MySql server if it is working by running sample sql queries

step-1

CREATE DATABASE mysql_test;

step-2

USE mysql_test;

step-3

CREATE TABLE table1 (id INT, name VARCHAR(45));

step-4

INSERT INTO table1 VALUES(1, 'jiban'), (2, 'kushal'), (3, 'Bholi'), (4, 'Akash');

step-5

SELECT * FROM table1;