MySQL GPG 密钥更新问题解决文档
MySQL GPG 密钥更新问题解决文档
问题描述
在 CentOS 7 系统上尝试更新 MySQL 包时遇到 GPG 密钥验证失败错误:
The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.Failing package is: mysql-community-client-8.0.43-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022, file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
问题原因
系统安装的旧版 MySQL GPG 密钥(2022年版本)与新版本 MySQL 8.0.43 包的数字签名不匹配,导致包验证失败。
环境信息
- 操作系统: CentOS 7.9
- MySQL 版本: 8.0.33 → 8.0.43
- 包管理器: YUM
- 问题时间: 2025-08-23
解决方案
步骤 1: 检查当前安装的 GPG 密钥
rpm -q --qf "%{name}-%{version}-%{release} %{summary}\n" gpg-pubkey | grep -i mysql
结果显示系统已安装的 MySQL GPG 密钥:
gpg-pubkey-3a79bd29-61b8bab7
gpg-pubkey-5072e1f5-5c4058fb
步骤 2: 下载新的 MySQL GPG 密钥
wget -O mysql-gpg-key.asc https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
步骤 3: 导入新密钥到 RPM 数据库
rpm --import mysql-gpg-key.asc
步骤 4: 验证新密钥已安装
rpm -q --qf "%{name}-%{version}-%{release} %{summary}\n" gpg-pubkey | grep -i mysql
确认新密钥已安装:
gpg-pubkey-a8d3785c-6536acda
(新安装的2023年密钥)
步骤 5: 重新执行 MySQL 包更新
yum update mysql-community-*
步骤 6: 验证更新结果
mysql --version
# 输出: mysql Ver 8.0.43 for Linux on x86_64 (MySQL Community Server - GPL)
更新详情
- 更新包数: 7 个 MySQL 相关包
- 升级版本: MySQL 8.0.33 → 8.0.43
- 更新包列表:
- mysql-community-client
- mysql-community-client-plugins
- mysql-community-common
- mysql-community-devel
- mysql-community-icu-data-files
- mysql-community-libs
- mysql-community-server
预防措施
为避免类似问题,建议:
- 定期更新 GPG 密钥:定期检查 MySQL 官方发布的 GPG 密钥更新
- 使用正确的密钥 URL:确保 YUM 仓库配置指向最新的密钥文件
- 在测试环境验证:在生产环境更新前先在测试环境验证
参考资料
- MySQL 官方 GPG 密钥下载:https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
- MySQL YUM 仓库配置:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html