How to Install MySQL 9.7 LTS on Ubuntu 24.04
Install MySQL 9.7 LTS on Ubuntu 24.04 with Oracle’s APT repository, verify the selected package, and create a database-scoped application account.
On this page
Ubuntu 24.04 LTS (Noble Numbat) can install MySQL 9.7 LTS from Oracle’s MySQL APT repository. This guide verifies that APT is using the noble/mysql-9.7-lts series before installing. Oracle’s repository instructions describe how to select a release series.
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 native Ubuntu MySQL packages; plan a separate migration if replacing MariaDB.
Prerequisites
- Ubuntu 24.04 LTS with internet access.
- A user account with
sudoprivileges. - A fresh installation, or a verified backup of any database you plan to replace.
Confirm the Ubuntu codename:
grep '^VERSION_CODENAME=' /etc/os-release
Ubuntu 24.04 should report noble. Stop if the codename differs; use instructions that match the system 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 package information and check the candidate:
sudo apt update
apt-cache policy mysql-server
Confirm that APT’s candidate comes from Oracle’s noble/mysql-9.7-lts repository. Oracle’s Ubuntu Noble 9.7 LTS package index currently lists mysql-server; maintenance versions can change. If the candidate is missing or points to another release series, reconfigure the repository with sudo dpkg-reconfigure mysql-apt-config, select mysql-9.7-lts, and refresh APT 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 to use local socket authentication. Check the server version with 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
Connect as the administrator using the method above, then create a sample database, table, and account. The application account receives access only to this database:
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 remotely, replace localhost with the narrowest host pattern that matches that client. Grant schema-change privileges separately to a migration account if needed.
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 Ubuntu 22.04 installation guide. For MySQL 9.7 LTS on Ubuntu 26.04, see the Ubuntu 26.04 installation guide. For more database material, visit our MySQL tutorials and MySQL Reference.