Menu

How to Install MySQL 8.4 LTS on Ubuntu 22.04

Install MySQL 8.4 LTS on Ubuntu 22.04 with Oracle’s MySQL APT repository, then verify the server and service.

Posted on By Updated on
On this page

This guide installs MySQL 8.4 LTS on Ubuntu 22.04 from Oracle’s MySQL APT repository. If you prefer MySQL 9.7 LTS on this same Ubuntu release, see the MySQL 9.7 guide for Ubuntu 22.04. For MySQL 9.7 LTS on newer Ubuntu releases, see the Ubuntu 24.04 guide or Ubuntu 26.04 guide.

Prerequisites

Before you install MySQL, you need to have the following prerequisites:

  • Ubuntu 22.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
echo '981ff0a16aab27a0cd97f4c4ee49e9fd  mysql-apt-config_0.8.40-1_all.deb' | md5sum --check
sudo dpkg -i mysql-apt-config_0.8.40-1_all.deb

The checksum is listed on the MySQL APT download page. If Oracle publishes a newer configuration-package version, use its matching filename and checksum.

In the configuration dialog, select MySQL Server & Cluster, then choose the mysql-8.4-lts series. Refresh APT’s package information:

sudo apt update

Check which server version APT will install:

apt-cache policy mysql-server

Confirm the candidate comes from the jammy/mysql-8.4-lts repository before proceeding. If it shows 8.0 or another source, re-open the repository configuration and select mysql-8.4-lts.

Step 3 - Install MySQL Server

Now install MySQL server:

sudo apt install mysql-server

Because you selected mysql-8.4-lts and confirmed the candidate above, this installs MySQL 8.4 LTS rather than the native Ubuntu package. The APT package starts the server after installation.

Verify MySQL Server

The APT package starts the service after installation. Check the client and service, then query the server version:

mysql --version
sudo systemctl status mysql --no-pager

The APT setup dialog lets you set a root password or leave it blank for local socket authentication. To check the server version, use the command for the authentication method you selected:

# For local socket authentication
sudo mysql -e 'SELECT VERSION();'

# If you set a root password
sudo mysql --user=root --password -e 'SELECT VERSION();'

The server version should be 8.4.x; the second command prompts for the password.

Optional post-install hardening

You can review additional installation-hardening prompts with sudo mysql_secure_installation; read each prompt before accepting its proposed change.

Create a database and limited application account

Connect as the administrative account using the method above, then create a sample database, table, and account. This application account receives access only to mytestdb, not global privileges:

CREATE DATABASE mytestdb;
CREATE TABLE mytestdb.users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50) NOT NULL
);
CREATE USER 'myapp'@'localhost' IDENTIFIED BY RANDOM PASSWORD;
GRANT SELECT, INSERT, UPDATE, DELETE ON mytestdb.* TO 'myapp'@'localhost';
SHOW GRANTS FOR 'myapp'@'localhost';

MySQL displays the generated password once. Store it in a password manager or application secret store. If the application connects from another host, replace localhost with the narrowest host value that matches that client. Add DDL privileges only to a separate migration account if the application needs to change the schema.

Test the application account

Connect to the sample database using the limited account:

mysql --user=myapp --password --database=mytestdb

Enter the generated password when prompted, then check the connected account, database, and server:

SELECT CURRENT_USER(), DATABASE(), VERSION();
SELECT * FROM users;

Conclusion

You installed MySQL 8.4 LTS from Oracle’s APT repository, verified the selected package version, and tested a database-scoped application account. For MySQL 9.7 LTS on newer Ubuntu, see the Ubuntu 26.04 installation guide.

If you want to learn more about MySQL, please use our MySQL tutorials and MySQL Reference.