Why MySQL 8.4 LTS (and Not 8.0)

MySQL 8.0 reached end of life on 30 April 2026, which means no more security patches. If you install 8.0 today, you are deploying a database with known, unpatched vulnerabilities. MySQL 8.4 is the current Long Term Support release, supported until 2032, with a faster optimizer, better replication stability, and saner defaults.

Ubuntu 24.04's default repositories still ship MySQL 8.0, so we will add Oracle's official MySQL APT repository and pin it to the mysql-8.4-lts track. By the end of this guide you will have a secured MySQL 8.4 LTS server running on Ubuntu 24.04, with a database and an application user ready to go.

Prerequisites

  • Ubuntu 24.04 server (22.04 works too) with sudo access
  • At least 1 GB RAM and 2 GB free disk space
  • A terminal / SSH session to the server

Step 1: Update the System

Always start from a clean, updated package index so nothing conflicts with the new repository.

sudo apt update && sudo apt upgrade -y

This refreshes the package lists and applies pending updates. Reboot if a new kernel was installed.

Step 2: Add the Official MySQL APT Repository

Download the MySQL APT configuration package. At the time of writing the current file is mysql-apt-config_0.8.40-1_all.deb; check the MySQL APT downloads page and adjust the version if a newer one is listed.

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

Install it with dpkg:

sudo dpkg -i mysql-apt-config_0.8.40-1_all.deb

A blue configuration screen appears. Select MySQL Server & Cluster, press Enter, then choose mysql-8.4-lts and confirm with OK. This tells apt to pull MySQL 8.4 LTS instead of the older 8.0 line. If you ever need to change the selection later, run sudo dpkg-reconfigure mysql-apt-config.

Step 3: Refresh apt and Confirm the 8.4 Packages

sudo apt update

Now verify that apt sees the 8.4 packages from the MySQL repo:

apt-cache policy mysql-server

In the output you should see a candidate version starting with 8.4. from repo.mysql.com. If you still see 8.0.x from Ubuntu's own archive, the repository selection in Step 2 did not stick; re-run the dpkg-reconfigure command.

Step 4: Install MySQL Server 8.4

sudo apt install -y mysql-server

This installs the 8.4 LTS server, client tools, and starts the mysql systemd service automatically. Check that it is running:

sudo systemctl status mysql --no-pager

Confirm the installed version:

mysql --version

You should see something like mysql Ver 8.4.x for Linux on x86_64.

Step 5: Run the Security Hardening Script

MySQL ships with an interactive hardening wizard. On Ubuntu, run it with sudo because the root account uses socket authentication by default:

sudo mysql_secure_installation

Answer the prompts:

  • VALIDATE PASSWORD COMPONENT: yes is fine for production; it enforces password strength.
  • Set a root password if you want password login for root (optional; socket auth still works).
  • Remove anonymous users: yes.
  • Disallow root login remotely: yes.
  • Remove test database: yes.
  • Reload privilege tables: yes.

Step 6: Create a Database and an Application User

Never run your app as root. Log in and create a dedicated database and user:

sudo mysql

Inside the MySQL shell, run:

CREATE DATABASE myapp_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'myapp'@'localhost' IDENTIFIED BY 'Str0ng!Passw0rd';
GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Two things worth knowing about 8.4: the default authentication plugin is caching_sha2_password (the old mysql_native_password is disabled by default in 8.4, so very old client libraries may need an upgrade), and utf8mb4 is the charset you want for full Unicode support including emojis.

Step 7 (Optional): Allow Remote Connections

By default MySQL listens only on localhost. If your app runs on another server, edit the bind address:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Change bind-address = 127.0.0.1 to bind-address = 0.0.0.0 (or your server's private IP), then create a remote-capable user and open the firewall:

sudo mysql -e "CREATE USER 'myapp'@'%' IDENTIFIED BY 'Str0ng!Passw0rd'; GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp'@'%'; FLUSH PRIVILEGES;"
sudo ufw allow 3306/tcp
sudo systemctl restart mysql

Only do this if you actually need remote access; every open port is attack surface. Prefer a VPN or SSH tunnel when possible.

Verify It Worked

Run these three checks:

mysql --version
sudo systemctl is-active mysql
mysql -u myapp -p -e "SELECT VERSION();"

The first prints 8.4.x, the second prints active, and the third logs in as your app user and prints the server version. If all three pass, your MySQL 8.4 LTS install is live and usable.

Common Issues & Fixes

1. ERROR 1698 (28000): Access denied for user 'root'@'localhost'

On Ubuntu, root authenticates via the Unix socket, not a password. Always use sudo mysql instead of mysql -u root -p. If you need password-based root access, set it explicitly with ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpassword';.

2. apt still wants to install MySQL 8.0

The APT repo selection did not apply. Re-run sudo dpkg-reconfigure mysql-apt-config, pick mysql-8.4-lts under MySQL Server & Cluster, then sudo apt update and check apt-cache policy mysql-server again.

3. Old app fails with "caching_sha2_password" / "mysql_native_password" errors

MySQL 8.4 disables mysql_native_password by default. The right fix is upgrading the client library (any maintained connector from the last few years supports caching_sha2_password). As a temporary workaround you can re-enable the old plugin, but do not leave it that way in production.

4. dpkg was interrupted during the config package install

If the terminal dropped mid-install, repair it with:

sudo dpkg --configure -a
sudo apt install -f

Then continue from Step 3.

5. MySQL fails to start after changing bind-address

A typo in mysqld.cnf is the usual cause. Check the error log with sudo journalctl -u mysql --no-pager | tail -30, fix the config line, and restart with sudo systemctl restart mysql.

Conclusion

You now have MySQL 8.4 LTS running on Ubuntu 24.04, hardened, with a dedicated database and user. Because 8.4 is an LTS release supported until 2032, this is a setup you will not need to revisit for years. If you are still on MySQL 8.0 anywhere, plan that upgrade soon: 8.0 stopped receiving security patches in April 2026.

Need help with server setup, migrations, or managed hosting? XpertBees handles exactly this kind of infrastructure work every day.