MySQL is the popular relational database management system used for storing structured data in table formats. It is open source database server uses SQL (Structured Query Language) statements for to interact with. The MySQL is freely available under the terms of the GNU General Public License. In this article we are going to learn “How to Install Mysql 8.0 on Ubuntu 20.04/22.04 LTS?”


MySQL is a popular open-source relational database management system used by developers and system administrators for a wide range of applications. In this tutorial, we will guide you through the process of installing MySQL 8 on an Ubuntu 20.04/22.04 LTS server, enabling you to set up a powerful and reliable database system.


  • An Ubuntu 20.04 server.
  • Access to a terminal window with sudo privileges.

Steps to Install Mysql 8.0 on Ubuntu 20.04/22.04 LTS

Let’s see the steps of “How to Install Mysql 8.0 on Ubuntu 20.04/22.04 LTS?”. Follow the guide in order without missing any step.

Step #1: Update Package Lists

Before installing any software, ensure that your package lists are up to date. Open a terminal and run the following command:

ubuntu@Rushi-InfoTech:~$ sudo apt-get update

Step #2: Enable MySQL PPA

  • MySQL team provides official MySQL PPA for Ubuntu operating systems. You can download and install the package on your Ubuntu 20.04/22.04 system, which will add PPA file to your system. Run below command to enable PPA.
ubuntu@Rushi-InfoTech:~$ wget
ubuntu@Rushi-InfoTech:~$ sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
  • Select the Ubuntu bionic and press on Enter.
  • Select on Ok and press Enter.

Step #3: Installing MySQL 8 on Ubuntu

  • Update cache – Execute below command to update apt cache on your system.
ubuntu@Rushi-InfoTech:~$ sudo apt-get update
  • Install MySQL – finally install the MySQL server packages.
ubuntu@Rushi-InfoTech:~$ sudo apt install mysql-server

Press “y” and press on enter to proceed the installation.

  • To set a root password enter into the mysql database by the following command:
ubuntu@Rushi-InfoTech:~$ sudo mysql
  • Run the following command to set a root password:
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'Rushi@123';

Replace the “Rushi@123” into your password to set as password for root user.

  • To exit from mysql database to Ubuntu server enter “exit”
mysql> exit

Step #4: Secure MySQL Installation

  • Execute the below command on your system to make security changes on your Database server. This will prompt some questions. The do the high security provide all answers to yes.
sudo mysql_secure_installation


ubuntu@Rushi-InfoTech:~$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...

 - Removing privileges on test database...

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done!
  • If you try again to enter into root user without password you reflect an error.
ubuntu@Rushi-Infotech:~$ sudo mysql
  • To Enter into mysql database as root user with password we need to enter following command.
ubuntu@Rushi-Infotech:~$ mysql -u root -p

You need to enter your root password which you have set before as “Rushi@123” to enter into mysql database.

  • Now verify the version present of mysql on ubuntu 20.04/22.04 LTS.

Here we go, We have successfully installed the mysql on Ubuntu 20.04/22.04 LTS and we are present in mysql database.


You have successfully installed MySQL 8 on your Ubuntu 20.04/22.04 LTS server. MySQL is now ready to be used as a powerful relational database management system for your applications. Be sure to keep your MySQL server and data secure by following best practices for database administration.

To know more about MySQL please visit official website.

Any queries pls contact us @Rushi-InfoTech

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *