Knowledge Base

How to install MySQL 5.7 server and client on Ubuntu 22.04 LTS Linux

The current MySQL server version to install through the Ubuntu 22.04 repository is 8.0, however, for some reason, if you need MySQL 5.7 then in this tutorial we learn how to install that. MySQL 5,7 is not supported anymore that’s the reason it is not available from the base repository of the latest Linux. However, still, users of the Ubuntu 22.04 LTS (Long Term Support) version can install MySQL 5.7 by adding its repo manually.

 

1. Update Ubuntu 22.04

It is important to start with updating our system because this not only helps Ubuntu to get security packages but also refreshes the package index cache of the APT package manager.

apt update && sudo apt upgrade

 

2. Installing necessary packages

There are a few packages we need on our system for installing MySQL 5.7 server on Ubuntu 22.04, therefore first configure them using the below-given command.

apt install dirmngr ca-certificates software-properties-common apt-transport-https wget

 

3. Configure MySQL 5.7 Repository

As we know by default Ubuntu 22.04 will not let us install the MySQL 5.7 Database version, therefore, we manually need to configure an old repository available for it. First, download the Debian package to configure MySQL 5.7 repository using the given command

wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb

 

Install the downloaded Deb file from mysql.com using the DPKG package management tool.

dpkg -i mysql-apt-config_0.8.12-1_all.deb

 

As we are on the Ubuntu jammy which is not supported system by MySQL 5.7, hence we have to select the Ubuntu version that supports this old version of Oracle Database. So, choose the Ubuntu bionic using the arrow keys and hit the Enter key.
You will have a “Configure mysql-apt-config” display in your Terminal. Select the first option “MySQL Server & Cluster (Currently Select: mysql-8.0” and hit the Enter key.
You will see MySQL-5.7 in the product list that we want on Ubuntu Jammy, so select that and press the Enter key to move forward.
Finally, we have done all the settings for the MySQL 5.7 repository to add to your system. Simply with the help of the arrow keys select OK and press Enter key.


4. Add GPG key for MySQL 5.7 on Ubuntu 22.04

Well, as you add the repository of MySQL 5.7, a warning apt-key is deprecated will appear because Ubuntu 22.04 stores GPG keys in ‘trusted.gpg.d’ that are used only for their respective repository’s packages to install or update.

So, to remove this warning manually add the GPG key for MySQL 5.7 in Ubuntu 22.04’s trusted.gpg.d directory.

gpg --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29

gpg --export --armor 467B942D3A79BD29 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/mysql.5.7-key.gpg

 

Run system update:

apt update

 

5. Installing MySQL 5.7 in Ubuntu 22.04 Server

Finally, we have configured the repository properly and now we can download the MySQL 5.7 server and client packages from it using the default APT package manager of Ubuntu.

Note: If you have already MariaDB installed then first completely remove it.

Here is the command to follow:

apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*

We are using -f flag to forcefully install version 5,7 otherwise due to priority, the system keeps preferring 8.0 and through an error.

While installing, the process will ask you to set a root password for the MySQL Database server. Set some strong password…

 

6. Verifying service status

To ensure MySQL service is running in the background once the installation process is completed, check it.

systemctl status mysql --no-pager -l

Please rate this article to help us improve our Knowledge Base.

0 0