Install MySQL 8 on Ubuntu/Linux Mint

Ubuntu official software repository provides MySQL 5.x which can be installed by following the article: Install MySQL with phpMyAdmin on Ubuntu. However the latest release of MySQL: 8.x, requires you to manually add the software repository into your system which makes the installation process little tricky. This article walks you through the end-to-end installation process of MySQL 8.


Step 1:
Download the latest mysql-apt-config_0.8.xx-x_all.deb file from the official site:




In this article, I am using mysql-apt-config_0.8.13-1_all.deb. Please change the commands when you copy and paste in your terminal according to the version you have downloaded.

Step 2:
Install the file using the following command:
sudo dpkg -i  mysql-apt-config_0.8.13-1_all.deb

If you are using an Ubuntu (or Debian) derivative like Linux Mint, you might be asked to select the upstream version as shown below:


Select the upstream version using up or down arrow keys, press Tab to select Ok and hit the enter.

If you don't know the upstream version, enter the following command to see the upstream version.
cat /etc/upstream-release/lsb-release
For example, I am using Linux Mint 19.2 Tina which is based on Ubuntu 18.04 Bionic Beaver.

Step 3:
Later you will be asked to choose the product. MySQL 8.0 will be selected by default which is what we are looking for. Therefore select Ok using the down arrow key, press the Tab to select Ok and hit the enter.


After this step, the APT config should be installed with no further hassles.

Step 4:
Enter the following command to update the software repositories.
sudo apt update

Step 5:
Install MySQL server using the following command:
sudo apt install mysql-server

You will be asked to confirm the installation. Press y and hit the enter to confirm the installation.


Step 6:
During the installation, the installer will ask you to choose a password for the root user.


Enter a password for the root user, select Ok and hit enter. You will be asked to re-enter the password again in a similar dialog. Please re-enter the password and select Ok.

Step 7:
Next you will see an information message introducing the new SHA256-based password authentication and how it affects old clients. Read the message and select Ok.


Due to this change some clients like PhpMyAdmin may not work with MySQL 8. To get them working, you have to modify the default-auth-override.cnf file as mentioned in the above message.

Step 8:
Finally, the installer will ask you to choose the default authentication plugin. Select the recommended Strong Password Encryption plugin and select Ok.


At the end of this strep, MySQL 8 will be installed on your system. You can test the installation using mysql -u root -p command.

Step 9 [Optional]:
The default MySQL installation is not secure. It is highly recommended to secure the installation by entering the following command.
sudo mysql_secure_installation

It will ask you the following questions and I have listed the recommended answer for those questions.
  • Enter password for user root: <Your root Password>
  • Would you like to setup VALIDATE PASSWORD component? y
  • Estimated strength of the password: 2
  • Change the password for root ? (Only if you root password does not meet the strength you set, you will be asked the following question. I've chosen no but it is recommended to say yes and change your password for root. Especially if it is a production environment)
  • Remove anonymous users? y
  • Disallow root login remotely? y
  • Remove test database and access to it? y
  • Reload privilege tables now? y

Step 9:
Restart the MySQL service using the following command:
sudo systemctl restart mysql

Step 11:
See if you can login to the MySQL client using the following command:
mysql -u root -p



If you have any questions or feedback, please comment below. I will try my best to help you.
Latest
Previous
Next Post »

Contact Form

Name

Email *

Message *