Debian 11.5执行apt-get update时MySQL出现NO_PUBKEY和EXPKEYSIG错误
解决Debian 11.5下MySQL仓库密钥过期导致的apt update报错
问题详情
执行apt-get update时出现密钥验证错误:
root@linode (apt ): apt-get update Hit:1 http://repo.mysql.com/apt/debian jessie InRelease Hit:2 https://packages.sury.org/php bullseye InRelease Hit:3 https://deb.nodesource.com/node_14.x bullseye InRelease Hit:4 http://httpredir.debian.org/debian bullseye InRelease Err:1 http://repo.mysql.com/apt/debian jessie InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8C718D3B5072E1F5 Hit:5 http://apt-longview.linode.com bullseye InRelease Hit:6 http://httpredir.debian.org/debian bullseye-updates InRelease Reading package lists... Done W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mysql.com/apt/debian jessie InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8C718D3B5072E1F5 W: Failed to fetch http://repo.mysql.com/apt/debian/dists/jessie/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8C718D3B5072E1F5 W: Some index files failed to download. They have been ignored, or old ones used instead.
尝试导入旧密钥后出现密钥过期错误:
root@linode (apt ): gpg --keyserver keyring.debian.org --recv-keys 8C718D3B5072E1F5 root@linode (apt ): gpg --export 8C718D3B5072E1F5 | sudo apt-key add - Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). OK W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mysql.com/apt/debian jessie InRelease: The following signatures were invalid: EXPKEYSIG 8C718D3B5072E1F5 MySQL Release Engineering <mysql-build@oss.oracle.com> W: Failed to fetch http://repo.mysql.com/apt/debian/dists/jessie/InRelease The following signatures were invalid: EXPKEYSIG 8C718D3B5072E1F5 MySQL Release Engineering <mysql-build@oss.oracle.com>
解决方案
1. 删除过期的旧密钥
8C718D3B5072E1F5密钥已过期,先移除它:
apt-key del 8C718D3B5072E1F5
2. 导入MySQL官方最新签名密钥
使用apt推荐的密钥管理方式,将密钥存储到/usr/share/keyrings目录:
wget -O - https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 | gpg --dearmor | tee /usr/share/keyrings/mysql-archive-keyring.gpg > /dev/null
3. 修正MySQL仓库源配置
当前系统是Debian 11(bullseye),但你使用的是Debian 8(jessie)的MySQL仓库,版本不匹配且已停止维护,需要修改仓库源:
- 找到MySQL源配置文件,通常位于
/etc/apt/sources.list.d/mysql.list - 编辑该文件,将所有
jessie替换为bullseye,并添加密钥验证路径,最终内容示例:
deb [signed-by=/usr/share/keyrings/mysql-archive-keyring.gpg] http://repo.mysql.com/apt/debian/ bullseye mysql-8.0
(如果需要安装MySQL 5.7,可将mysql-8.0改为mysql-5.7,但推荐使用适配bullseye的8.0版本)
4. 重新更新软件源
执行以下命令验证问题是否解决:
apt-get update
内容的提问来源于stack exchange,提问作者Rich
相关产品推荐
相关产品推荐

