How to Install MySQL On Ubuntu 20.04

Install MySQL in Ubuntu 18.04; In this tutorial, i am going to show you how to install and secure MySQL on a Ubuntu 20.04 System.  

MySQL server is a SQL complaint server, in other words it is a relational model database server. It is very popular because it is free. It was developed by Sun and moved to Oracle when Oracle acquired Sun. Oracle continued improving it.

How to Install MySQL On Ubuntu 20.04

Use the below given steps to install and secure MySQL in Ubuntu 20.04

Step 1 – Update System Packages

Open terminal and execute the following command on terminal to update the apt package:

sudo apt-get update

Step 2 – Install Mysql on Ubuntu

Now, execute the following command on terminal to install the MySQL package on ubuntu:

sudo apt-get install mysql-server

Step 3 – Secure MySQL Server Installation

Default MySQL is insecure , we need to secure the database server.

After installation is complete, the mysql_secure_installation utility runs.
Run the below command and answer the few questions based on your environment requirements.

sudo mysql_secure_installation

Step 4 – Restart MySQL Server

MySql installation process is completed, the MySQL service will start automatically. To check MySQL server is running properly, To use this command :

systemctl status mysql.service 

You’ll see output similar to the following :

 mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
   Active: active (running) since Wed 2018-12-20 10:44:25 PDT; 4min ago
 Main PID: 3754 (mysqld)
    Tasks: 28
   Memory: 142.3M
      CPU: 1.994s
   CGroup: /system.slice/mysql.service
           └─3754 /usr/sbin/mysqld

Stop MySql service :

systemctl stop mysql

Start MySql service :

systemctl start mysql

Step 5 – Launch MySQL to Enter Commands

Many MySQL commands can be entered from the MySQL command shell.  This is very similar to a terminal window, but the commands are issued directly to the MySQL service.  From a regular terminal window, enter the following:

sudo mysql –u root –p

The system should prompt for a password, then give an introduction to the MySQL shell.  The command prompt will change to look like this:

mysql>

Conclusion

That’s It! In this tutorial, i have shown to you how to install MySQL 8.0 in Ubuntu 20.04 .

Leave a Comment