MySQL 8 on Ubuntu 20.04: Legacy Installation Guide
Legacy Ubuntu 20.04 guide. Standard support ended in May 2025, and Oracle’s Focal repository still lists MySQL 8.0.42.
On this page
This page documents the former MySQL installation procedure for Ubuntu 20.04 (Focal). Keep it only for reference when diagnosing existing legacy hosts.
Repository status: Do not use the Focal commands below for a new or production server. Oracle’s Focal MySQL 8.0 package index currently lists MySQL 8.0.42-1ubuntu20.04, below the final MySQL 8.0 release, 8.0.46. Ubuntu 20.04 standard security maintenance ended in May 2025; Ubuntu Pro ESM is listed through April 2030. For an existing MySQL 8.0 instance, follow the MySQL 8.0 to 8.4 upgrade guide and verify that the target operating system is supported. For a new server, see our MySQL 9.7 LTS guide for Ubuntu 26.04. Check OS coverage in Ubuntu’s release list and MySQL lifecycle details in the MySQL 8.0 release notes.
Prerequisites
Before you install MySQL, you need to have the following prerequisites:
- Ubuntu 20.04 server with a non-root user with sudo privileges
- An internet connection
Step 1 - Update Package Repository
First, update your Ubuntu package repository:
sudo apt update
Step 2 - Add the MySQL APT Repository
Install the current MySQL APT repository configuration package. As of September 2026, the package is 0.8.40-1:
sudo apt install -y wget
wget https://dev.mysql.com/get/mysql-apt-config_0.8.40-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.40-1_all.deb
In the configuration dialog, select MySQL Server & Cluster, then choose the mysql-8.0 series. Refresh APT’s package information:
sudo apt update
Step 3 - Install MySQL Server
Now install MySQL server:
sudo apt update
sudo apt install mysql-server
This will install MySQL 8.0.
Step 4 - Start MySQL Service
Once installed, the MySQL service will start automatically. You can check it with:
sudo systemctl status mysql
Step 5 - Secure MySQL
It’s recommended that you run the mysql_secure_installation script to improve MySQL security:
sudo mysql_secure_installation
This will set the root password, remove anonymous user accounts, disable root logins outside localhost, etc.
Step 6 - Create a Dedicated MySQL User
It’s best practice to create a dedicated MySQL user for your applications instead of using the root account:
sudo mysql
Run the following SQL as an administrator. The application user receives access only to the sample database:
CREATE DATABASE IF NOT EXISTS mytestdb;
-- MySQL 8.0.18+ returns a generated password; save it securely for the connection test.
CREATE USER 'myuser'@'localhost' IDENTIFIED BY RANDOM PASSWORD;
-- CREATE is included for the sample table; use a separate migration account for schema changes in production.
GRANT CREATE, SELECT, INSERT, UPDATE, DELETE ON mytestdb.* TO 'myuser'@'localhost';
Choose the account name you need, then save the generated password shown by MySQL in a secure secret store; do not reuse it or commit it to application code.
Step 7 - Test MySQL
To test if MySQL is working properly, connect to the mysql server with the new user created:
mysql -u myuser -p
Enter the password when prompted. Then you’ll enter into the MySQL shell.
Run a simple command to test connectivity:
SHOW DATABASES;
This will show the available databases.
Step 8 - Create a Sample Table
The administrator created mytestdb in the previous step. Create a sample table in it:
USE mytestdb;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
email VARCHAR(50)
);
The server is installed. Because MySQL 8.0 reached end of life in April 2026, keep this procedure for existing legacy systems only; do not choose this series for a new production deployment.
Conclusion
This guide documents the MySQL 8.0 package still available for Ubuntu 20.04 systems under Ubuntu Pro ESM. For a new installation, use a supported operating-system release and a maintained LTS series; see MySQL 9.7 LTS on Ubuntu 26.04.
If you want to learn more about MySQL, please use our MySQL tutorials and MySQL Reference.