SolvedIssues
Fixes we actually ran — not copied.
← All fixes

apt installs MySQL 8.0 instead of 8.4 (and your backup won't load)

MySQL Ubuntu 24.04 ✓ Verified 2026-06-04

The problem

You add the official MySQL APT repository to install MySQL 8.4, but apt keeps installing Ubuntu's MySQL 8.0 instead. When you then restore an 8.4 data folder, MySQL refuses to start.

What you'll see

The way most sites tell you — and why it fails

✗ What the copied tutorials say

Almost every guide tells you to add the repo with the signed-by keyring fetched from repo.mysql.com/RPM-GPG-KEY-mysql-2023, claiming MySQL 'renewed the key to 2027'.

curl -fsSL https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 | sudo gpg --dearmor -o /usr/share/keyrings/mysql.gpg
echo 'deb [signed-by=/usr/share/keyrings/mysql.gpg] http://repo.mysql.com/apt/ubuntu/ noble mysql-8.4-lts mysql-tools' | sudo tee /etc/apt/sources.list.d/mysql.list
sudo apt update
sudo apt install -y mysql-server

Why it fails: MySQL's live repository is STILL signed with the expired key, so apt rejects it (EXPKEYSIG) and disables it. With MySQL's repo off, the package name 'mysql-server' resolves to the only one left -- Ubuntu's 8.0. The guides repeat each other and never test it, so the stale 'key was renewed' claim spreads everywhere.

The correct way — we tested this

✓ Do this instead

Trust the repo past the broken key with [trusted=yes], and install the server by its EXACT Oracle package name (mysql-community-server) so Ubuntu's 8.0 cannot be substituted.

echo 'deb [trusted=yes] http://repo.mysql.com/apt/ubuntu/ noble mysql-8.4-lts mysql-tools' | sudo tee /etc/apt/sources.list.d/mysql.list
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y mysql-community-server
mysql --version    # must show 8.4.x

Why this works

[trusted=yes] tells apt to skip signature verification for that one repository, so MySQL's expired key no longer blocks it. Ubuntu has no package literally named 'mysql-community-server', so apt can only get it from MySQL's repo -- guaranteeing you the 8.4 series. The expired key, which was the real cause, is removed from the path entirely instead of being worked around with a key that is itself expired.