apt update fails: the MySQL repository signature cannot be verified
The following signatures couldn't be verified because the public key is not available: NO_PUBKEYShort 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.
Fix it fast
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-config2Match what you see, then jump to its fix
- 1
A 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
You 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
- 1
What does the error look like?
The following signatures couldn't be verified because the public key is not available: NO_PUBKEYW: 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-config2Fix
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 update3Verify
apt-get update finishes without a MySQL signature error, and the server package shows a candidate version.
apt-cache policy mysql-serverConfirmed by dev.mysql.com
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 update3Verify
No MySQL line is left in the update output except normal Get and Hit lines.
sudo apt-get updateConfirmed by dev.mysql.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Locked out of a fresh MariaDB install as root on Mac or Linux
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
A fresh MariaDB root account is not a normal password account.
3 causes, each with a fixDatabases
An Aria table fails with 'Read page with wrong checksum' (error 1030, code 176)
ERROR 1030 (HY000): Got error 176 "Read page with wrong checksum" from storage engine Aria
Code 176 means MariaDB's Aria engine read a data or index page whose checksum does not match, so that table file is damaged.
3 causes, each with a fixDatabases
The client cannot open a TCP connection to MariaDB or MySQL (error 2003)
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)
Error 2003 means the client tried a TCP connection to the host and port and nobody answered.
4 causes, each with a fix