How to Install MySQL in Ubuntu Server?

By Hardik Savani December 24, 2021 Category : Ubuntu Server

Hi,

Today, i will let you know example of how to install mysql in ubuntu. We will look at example of how to install mysql in ubuntu 20.04 using terminal. i explained simply about ubuntu install mysql server example. let’s discuss about install mysql in ubuntu server.

In this post, i will give you simple list of commands how to install mysql server in ubuntu linux server. so let's see simple terminal command for install mysql in ubuntu ubuntu 21.10, ubuntu 21.04, ubuntu 20.04, ubuntu 18.04 and ubuntu 16.04.

Install MySQL on Ubuntu

Update Local Package:

sudo apt update

Install MySQL Server:

sudo apt install mysql-server

you can see terminal layout as bellow:

Access MySQL:

Now you can access mysql by using mysql command:

sudo mysql

OR

mysql -u root

you can see terminal layout as bellow:

MySQL Status:

you can check status of mysql server

systemctl status mysql.service

Create User on MySQL:

you can create new user for mysql by using following query:

sudo mysql

CREATE USER 'root_new'@'localhost' IDENTIFIED BY 'rootnewpassword';

GRANT ALL PRIVILEGES ON * . * TO 'root_new'@'localhost';

FLUSH PRIVILEGES;

I hope it can help you....

Tags :
Shares