install mysql in ubuntu

Install MySQL 8.0 in Ubuntu 20.04

MySQL is one of the most popular databases used by millions of websites around the world. It is a relational database that supports client-server architecture on Linux, Windows & Mac systems. In this article, we will look at how to install MySQL in Ubuntu 20.04. You can also use these steps to install MySQL in Ubuntu 16.04/18.04.


Install MySQL 8.0 in Ubuntu 20.04

Here are the steps to install MySQL 8.0 in Ubuntu 20.04.


1. Add MySQL Repository

Open terminal and run the following command to add MySQL package repository to Ubuntu source list.

$ sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.16-1_all.deb

After it is downloaded, run the following command to install the repository.

$ sudo dpkg -i mysql-apt-config_0.8.16-1_all.deb

Also read : How to Implement SSL/TLS in Apache Tomcat


2. Complete the installation

You will see a prompt which asks you whether you want to install MySQL Server, cluster or preview packages. Select the first option (MySQL Server) that will be already highlighted by default and click ok.

Next, you will see a prompt that asks you to select the appropriate software package for your system. Select MySQL 8.0 and click ok.

Also read : How to Change Time zone in Ubuntu


3. Update MySQL Repository

Run the following command to update system packages including MySQL repository.

$ sudo apt-get update

Also read : How to Use Curl to Download Files in Linux


4. Install MySQL Server & Client

Install MySQL Server & Client using the following command.

$ sudo apt install mysql-client mysql-community-server mysql-server

Enter y for any prompts you see. During installation, you will be asked to enter & re-enter root password. Use a password that is not easy to guess and is a combination of alphabets, numbers & special characters.

Also read : How to Install MongoDB in Ubuntu


5. Secure MySQL Installation

Secure MySQL installation to avoid unauthorized access to your database and improve security of your database. You can do this with the following command.

$ sudo mysql_secure_installation

You will see the following set of prompts that allows you to configure the security of your database.

Enter current password for root (enter for none): <Enter password>;
VALIDATE PASSWORD PLUGIN 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 plugin? 

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: 1 
Using existing password for root. 

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


Remove anonymous users? [Y/n] Y 
Disallow root login remotely? [Y/n] Y 
Remove test database and access to it? [Y/n] Y 
Reload privilege tables now? [Y/n] Y 
Thanks for using MySQL!

Also read : How to Raise Exception in Python


6. Verify Installation

Run the following command from terminal to verify MySQL installation.

$ sudo mysql -u root -p

Enter the root password to log into your database. Enter the following command to check MySQL version.

mysql> select version();

That’s it. MySQL will be installed on your Ubuntu system. You can use these steps on other Debian systems also.

Also read : How to Install PHPMyAdmin in Ubuntu


Leave a Reply

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