Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

apt update fails: the MySQL repository signature cannot be verified

ErrorThe following signatures couldn't be verified because the public key is not available: NO_PUBKEY

Short answer

apt rejects the MySQL repository when the key it has does not match the key the packages are signed with. MySQL changed its signing key for 8.0.44, 8.4.7 and 9.5.0 and later. Install the current mysql-apt-config package, or remove a hand-made repository entry and key, then run apt-get update again.

  • Applies to Ubuntu 24.04, Debian 12, MySQL 8.4 APT repository
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run the update and read the exact signature line. It names the key ID that apt could not use and the repository it came from.

    sudo apt-get update 2>&1 | grep -i -E "signature|NO_PUBKEY|mysql"
    dpkg -l | grep mysql-apt-config
  2. 2Match what you see, then jump to its fix

    1. 1A GPG error or NO_PUBKEY line for repo.mysql.com, after the repository worked beforeThe key on the system is older than the key the repository now signs withFix
    2. 2You followed an old guide: a hand-written .list file and a key that was added separately, and mysql-apt-config is not installedA key or repository entry was added by hand with the wrong keyFix

What does the error look like?

  • The following signatures couldn't be verified because the public key is not available: NO_PUBKEY
  • W: There are no public key available for the following key IDs:

Cause 1 of 2

The key on the system is older than the key the repository now signs with

1Check

The MySQL manual gives a new signing key ID, B7B3B788A8D3785C, for MySQL 8.0.44 and higher, 8.4.7 and higher, and 9.5.0 and higher. Earlier packages used the keys A8D3785C, 5072E1F5 or 3A79BD29. An old mysql-apt-config package still configures the old key.

dpkg -l mysql-apt-config

2Fix

Download the latest mysql-apt-config release package from the MySQL APT repository download page and install it with dpkg. The same package works on all supported Debian and Ubuntu platforms. Then refresh the package lists, which MySQL lists as a mandatory step.

sudo dpkg -i /PATH/mysql-apt-config_w.x.y-z_all.deb
sudo apt-get update

3Verify

apt-get update finishes without a MySQL signature error, and the server package shows a candidate version.

apt-cache policy mysql-server

Confirmed by dev.mysql.com

Did this fix it?

Cause 2 of 2

A key or repository entry was added by hand with the wrong key

1Check

The quick guide warns that using an incorrect key can cause a key verification error. Look for hand-written MySQL repository files.

grep -rl 'repo.mysql.com' /etc/apt/sources.list /etc/apt/sources.list.d/

2Fix

Remove the hand-written repository file, then install the mysql-apt-config package as in the first cause so the repository and its key are set up together. If you must configure it manually, take the key from the MySQL signature checking page and check its ID against the one for your release.

sudo rm /etc/apt/sources.list.d/your-old-mysql.list
sudo dpkg -i /PATH/mysql-apt-config_w.x.y-z_all.deb
sudo apt-get update

3Verify

No MySQL line is left in the update output except normal Get and Hit lines.

sudo apt-get update

Confirmed by dev.mysql.com

Did this fix it?

How do I stop it coming back?

  • Use the mysql-apt-config package instead of copying repository lines and keys from older guides.
  • Update mysql-apt-config when you upgrade to a new MySQL series, and run apt-get update after.
  • Check key IDs against the MySQL signature checking page before trusting any key.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.