How to Install MySQL 5.7 on Ubuntu 22.04

System update

# apt-get update
# apt-get install wget

Add MySQL 5.7 APT Repository

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

Install the MySQL APT Repository

# dpkg -i mysql-apt-config_0.8.22-1_all.deb

Update package lists

# apt update

Manually Configure the MySQL 5.7 APT Repository

Since Ubuntu 22.04 does not officially support MySQL 5.7, you need to use an older repository.

Add the MySQL Public GPG Key

# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C

Remove any existing MySQL repository

# rm -f /etc/apt/sources.list.d/mysql.list

Create a new MySQL APT repository file

# echo "deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql.list
# apt update
# sudo apt install mysql-server=5.7* mysql-client=5.7*
# mysql_secure_installation

Check mysql version

# mysql --version

Login to mysql

# mysql -u root -p

Remove any existing MySQL installation (if applicable)

# sudo apt remove --purge mysql-*
# sudo apt autoremove
# sudo apt clean

Leave a Reply

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