Menu

How to Install MySQL 9.7 LTS on Ubuntu 22.04

Install MySQL 9.7 LTS on Ubuntu 22.04 from Oracle’s APT repository, verify the Jammy candidate, and create a database-scoped application account.

Posted on By
On this page

Oracle’s MySQL APT repository publishes MySQL 9.7 LTS packages for Ubuntu 22.04 (Jammy). This guide selects that series explicitly and checks APT’s candidate before installation. See the MySQL APT repository instructions and the Jammy 9.7 LTS package index.

These steps assume a fresh MySQL installation. If MySQL or MariaDB is already installed, make and verify a backup before changing package sources. Oracle’s replacement guidance covers Ubuntu’s native MySQL packages; plan a separate migration if replacing MariaDB.

Prerequisites

  • Ubuntu 22.04 LTS with internet access.
  • A user account with sudo privileges.
  • A fresh installation, or a verified backup of any database you plan to replace.

Confirm that the system identifies itself as Jammy:

grep '^VERSION_CODENAME=' /etc/os-release

Add Oracle’s MySQL APT repository

Install the current MySQL APT repository configuration package. As of September 2026, it is version 0.8.40-1; check the MySQL APT download page if the filename or checksum changes:

sudo apt update
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

In the configuration dialog, select MySQL Server & Cluster, then choose mysql-9.7-lts. Refresh APT’s package information and check the candidate:

sudo apt update
apt-cache policy mysql-server

Confirm the candidate comes from Oracle’s jammy/mysql-9.7-lts repository. Oracle’s current package index lists MySQL 9.7 LTS for Jammy; maintenance versions can change. If the candidate is missing or points to another series, reconfigure the repository with sudo dpkg-reconfigure mysql-apt-config, select mysql-9.7-lts, and run sudo apt update again.

Install and verify MySQL

Install the server:

sudo apt install mysql-server
mysql --version
sudo systemctl status mysql --no-pager

APT starts the service after installation. During MySQL Server installation, you can set a password for the root account or leave it blank for local socket authentication. Check the server version using the connection 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 report 9.7.x. For additional hardening, review the prompts from sudo mysql_secure_installation before accepting its proposed changes.

Create a database and limited application account

Open an administrative MySQL prompt with sudo mysql for local socket authentication, or use sudo mysql --user=root --password if you set a root password. Then create a sample database, table, and account. This application account receives access only to sampledb:

CREATE DATABASE sampledb;
CREATE TABLE sampledb.users (
  user_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(255) NOT NULL UNIQUE
);
CREATE USER 'app_user'@'localhost' IDENTIFIED BY RANDOM PASSWORD;
GRANT SELECT, INSERT, UPDATE, DELETE ON sampledb.* TO 'app_user'@'localhost';
SHOW GRANTS FOR 'app_user'@'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 pattern that matches that client. Grant schema-change privileges separately to a migration account if required.

Test the application account:

mysql --user=app_user --password --database=sampledb

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

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

For MySQL 8.4 LTS on Ubuntu 22.04, see the MySQL 8.4 guide. For MySQL 9.7 LTS on Ubuntu 24.04 or 26.04, see the Ubuntu 24.04 guide or Ubuntu 26.04 guide. For more database material, visit our MySQL tutorials and MySQL Reference.