安装MySQL, GPG 密钥验证失败
Total 2.9 MB/s | 90 MB 00:00:30
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Importing GPG key 0x3A79BD29:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29
Package : mysql80-community-release-el7-7.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql80-community-release-el7-7.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Public key for mysql-community-client-8.0.43-1.el7.x86_64.rpm is not installed
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
[root@s22 ~]#

看到问题了,这是 GPG 密钥验证失败。我们需要解决密钥问题。以下是几种解决方案:
🔑 解决方案一:跳过 GPG 检查(不推荐用于生产)
# 使用 --nogpgcheck 参数跳过 GPG 检查
sudo yum install mysql-community-server mysql-community-client --nogpgcheck
🔑 解决方案二:正确导入 GPG 密钥
# 重新导入 MySQL GPG 密钥
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql
# 或者从本地文件导入(如果已下载)
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# 验证密钥是否导入成功
rpm -qa gpg-pubkey* | grep -i mysql
🔑 解决方案三:手动下载并安装 RPM 包
# 清理缓存
sudo yum clean all
# 手动下载所有必要的 RPM 包
wget https://repo.mysql.com/mysql-community-common-8.0.43-1.el7.x86_64.rpm
wget https://repo.mysql.com/mysql-community-libs-8.0.43-1.el7.x86_64.rpm
wget https://repo.mysql.com/mysql-community-client-8.0.43-1.el7.x86_64.rpm
wget https://repo.mysql.com/mysql-community-server-8.0.43-1.el7.x86_64.rpm
# 安装所有包(跳过 GPG 检查)
sudo rpm -ivh mysql-community-*.rpm --nodeps --force
🔑 解决方案四:配置 Yum 跳过 GPG 检查
# 编辑 MySQL 仓库配置
sudo vi /etc/yum.repos.d/mysql-community.repo
# 在每个 [mysql*] 部分添加
gpgcheck=0
或者临时禁用:
# 临时禁用所有仓库的 GPG 检查
sudo yum install mysql-community-server mysql-community-client --nogpgcheck
🎯 推荐执行顺序
我建议按以下步骤操作:
步骤 1:先尝试重新导入密钥
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
步骤 2:如果密钥导入失败,使用跳过 GPG 检查的方式
sudo yum install mysql-community-server mysql-community-client --nogpgcheck
步骤 3:如果上述方法都不行,手动下载安装
# 下载所有必要包
wget https://repo.mysql.com/mysql-community-common-8.0.43-1.el7.x86_64.rpm
wget https://repo.mysql.com/mysql-community-libs-8.0.43-1.el7.x86_64.rpm
wget https://repo.mysql.com/mysql-community-client-8.0.43-1.el7.x86_64.rpm
wget https://repo.mysql.com/mysql-community-server-8.0.43-1.el7.x86_64.rpm
# 安装(注意安装顺序)
sudo rpm -ivh mysql-community-common-8.0.43-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-8.0.43-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-8.0.43-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-server-8.0.43-1.el7.x86_64.rpm
⚠️ 注意依赖关系
如果手动安装遇到依赖问题,可以:
# 一次性安装所有包,自动解决依赖
sudo yum localinstall mysql-community-*.rpm --nogpgcheck
请先尝试方案二(重新导入密钥),如果不行再用方案一(跳过GPG检查)。 这两种方法应该能解决您的问题。

浙公网安备 33010602011771号