【mysql】解决MySQL GPG密钥过期问题

MySQL GPG 密钥过期,yum下载mysql-devel报错

正文开始@Assassin

记录make中的一次报错~~

刚刚centos7在执行make时遇到以下报错:
在这里插入图片描述

fatal error: mysql/mysql.h: No such file or directory
#include<mysql/mysql.h>
compilation terminated.

原因是找不到mysql.h头文件,于是使用以下命令安装对应的包:

sudo yum install mysql-devel

但是却出现了如下的报错:
只能说翻来覆去找了很久都没找到有用的方法,还是得StackOverflow
在这里插入图片描述

Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-devel-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


The GPG keys listed for the "MySQL 5.7 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-devel-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
 
==翻译:==
 
警告:/var/cache/yum/ x86_64/7/mysql57-community/packages/mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:/// etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

为“MySQL 5.7 社区服务器”存储库列出的 GPG 密钥已经安装,但它们对于这个包不正确。
检查是否为此存储库配置了正确的密钥 URL。

失败的包是:mysql-community-libs-compat-5.7.37-1.el7.x86_64
GPG 密钥配置为:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

症状:

官方 MySQL 存储库的 GPG 密钥已过期,无法安装或更新 MySQL 包。
为 “MySQL 5.7 社区服务器” 存储库列出的 GPG 密钥已经安装,但它们对于这个包不正确

错误类似于:

为“MySQL 8.0 社区服务器”存储库列出的 GPG 密钥已安装,但对于此包来说它们不正确。检查是否为此存储库配置了正确的密钥 URL。失败的包是:mysql-community-client-8.0.28-1.el8.x86_64 GPG 密钥配置为:http://repo.mysql.com/RPM- GPG-KEY-mysql
未安装 mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm 的公钥。失败的包是:mysql-community-client-plugins-8.0.28-1.el8.x86_64 GPG 密钥配置为:http://repo.mysql.com/RPM-GPG-KEY-mysql 
mysql-community 的公钥-common-8.0.28-1.el8.x86_64.rpm 未安装。失败的包是:mysql-community-common-8.0.28-1.el8.x86_64 GPG 密钥配置为:http://repo.mysql.com/RPM-GPG-KEY-mysql
未安装 mysql-community-devel-8.0.28-1.el8.x86_64.rpm 的公钥。失败的包是:mysql-community-devel-8.0.28-1.el8.x86_64 GPG 密钥配置为:http://repo.mysql.com/RPM-GPG-KEY-mysql 
mysql-community-icu 的公钥-data-files-8.0.28-1.el8.x86_64.rpm 未安装。失败的包是:mysql-community-icu-data-files-8.0.28-1.el8.x86_64 GPG 密钥配置为:http://repo.mysql.com/RPM-GPG-KEY-mysql 
mysql 的公钥-community-libs-8.0.28-1.el8.x86_64.rpm 未安装。失败的包是:mysql-community-libs-8.0.28-1.el8.x86_64 GPG 密钥配置为:http://repo.mysql.com/RPM-GPG-KEY-mysql
未安装 mysql-community-server-8.0.28-1.el8.x86_64.rpm 的公钥。失败的包是:mysql-community-server-8.0.28-1.el8.x86_64 GPG 密钥配置为:http://repo.mysql.com/RPM-GPG-KEY-mysql 错误:GPG 检查失败

描述:

MySQL GPG 密钥已过期。有关案例的其他详细信息也可以在 MySQL 网站上找到: https 😕/bugs.mysql.com/bug.php?id=106188

解决方法:

Note
If you are using RPM 4.1 and it complains about (GPG) NOT OK (MISSING KEYS: GPG#3a79bd29), even though you have imported the MySQL public build key into your own GPG keyring, you need to import the key into the RPM keyring first. RPM 4.1 no longer uses your personal GPG keyring (or GPG itself). Rather, RPM maintains a separate keyring because it is a system-wide application and a user’s GPG public keyring is a user-specific file. To import the MySQL public key into the RPM keyring, first obtain the key, then use rpm --import to import the key. For example:

可以在运行安装程序之前导入密钥:

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

Ubuntu:

wget -q -O - https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 | apt-key add -

之后再执行yum install mysql-devel 就over了
在这里插入图片描述
makefile:
在这里插入图片描述
在这里插入图片描述

<think>我们正在解决MySQLCommunityServer仓库的GPG密钥已安装但不适用于包的问题。用户在执行yum安装时可能遇到类似如下的错误:```Publickeyformysql-community-server-*.rpmisnotinstalled```尽管已经导入了GPG密钥,但yum仍然报告密钥不适用。这通常是由于密钥版本不匹配或缓存问题导致的。###解决方案步骤####1.**确认已安装的GPG密钥**首先,检查系统上已安装的MySQLGPG密钥:```bashrpm-qa|grep'gpg-pubkey'|grep-imysql```如果没有任何输出,说明密钥尚未安装。####2.**重新导入MySQLGPG密钥**如果密钥不存在或不确定,重新导入最新的MySQLGPG密钥:```bashsudorpm--importhttps://repo.mysql.com/RPM-GPG-KEY-mysql```验证导入是否成功:```bashrpm-qigpg-pubkey-$(rpm-qa|grep'gpg-pubkey'|grep-imysql|cut-d--f4)```这会显示MySQLGPG密钥的详细信息。####3.**清除YUM缓存并重建**有时候,旧的缓存可能导致问题:```bashsudoyumcleanallsudorm-rf/var/cache/yumsudoyummakecache```####4.**手动验证RPM包签名**尝试手动验证一个MySQL包的签名(例如,`mysql-community-server`):```bash#首先下载包但不安装sudoyuminstall--downloadonly--downloaddir=.mysql-community-server#验证签名rpm--checksigmysql-community-server-*.rpm```输出中应该包含`gpg`和`pgp`的`OK`标识,例如:```mysql-community-server-8.0.30-1.el7.x86_64.rpm:rsasha1(md5)pgpmd5OK```####5.**检查仓库配置中的GPG设置**确保MySQL仓库配置文件(`/etc/yum.repos.d/mysql-community.repo`)中启用了GPG检查:```[mysql-connectors-community]name=MySQLConnectorsCommunitybaseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/$releasever/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql```注意:`gpgcheck=1`必须存在。####6.**检查GPG密钥的适用性**如果以上步骤都正确,但问题仍然存在,可能是导入的GPG密钥与软件包使用的密钥不匹配。MySQL在2022年更换了新的GPG密钥[^1]。请确认你导入的是最新的密钥。可以尝试同时导入新旧两个密钥:```bashsudorpm--importhttps://repo.mysql.com/RPM-GPG-KEY-mysql-2022sudorpm--importhttps://repo.mysql.com/RPM-GPG-KEY-mysql```####7.**临时禁用GPG检查(不推荐)**作为临时解决方案,可以禁用GPG检查(仅用于测试,不推荐生产环境):```bashsudoyuminstall--nogpgcheckmysql-community-server```但这样做会降低安全性,应尽量避免。###常见问题原因-**密钥过期**:MySQL在2022年10月更换了新的GPG密钥,旧密钥已失效[^1]。-**仓库文件指向旧密钥**:确保仓库配置中的`gpgkey`指向正确的密钥路径(通常是`file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql`)。-**多密钥冲突**:如果系统中有多个MySQL密钥,移除旧密钥:```bashsudorpm-egpg-pubkey-<旧密钥ID>```>**重要提示**:MySQL8.0的仓库配置通常使用`mysql80-community-release`包管理,确保该包已正确安装并更新。§§相关问题§§1.如何验证RPM包的数字签名?2.MySQL官方仓库的GPG密钥更新后如何同步?3.如何解决yum安装过程中的GPG密钥错误?4.在CentOS/RHEL系统中如何管理多个GPG密钥?[^1]:[MySQL官方博客关于GPG密钥更换的说明](https://mysql.com)[^2]:使用rpm命令管理GPG密钥的详细方法</think>### 解决 MySQL Community Server 仓库的 GPG 密钥不适用问题 当出现 "GPG key installed but not applicable to package" 错误时,通常是因为系统无法验证 MySQL 软件包的数字签名。以下是完整的解决方案: #### 1. **验证密钥是否已正确安装** ```bash # 检查已安装的 GPG 密钥 rpm -qa gpg-pubkey* | grep -i mysql # 查看密钥详细信息 rpm -qi gpg-pubkey-$(rpm -qa | grep gpg-pubkey | grep mysql | cut -d- -f3) ``` 如果无输出,说明密钥未安装;如果有输出但报错,说明密钥不匹配[^1]。 #### 2. **重新导入最新 GPG 密钥** ```bash # 移除旧密钥(如果存在) sudo rpm -e gpg-pubkey-$(rpm -qa | grep gpg-pubkey | grep mysql | cut -d- -f3) # 导入 2022 年新密钥 sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 # 导入传统密钥 sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql ``` MySQL 在 2022 年更换了 GPG 密钥,必须导入新密钥才能验证最新软件包[^1]。 #### 3. **检查仓库配置** ```bash # 确认仓库文件配置 sudo cat /etc/yum.repos.d/mysql-community.repo # 确保每个仓库区块包含正确的 GPG 设置 [mysql-community-server] gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 ``` #### 4. **强制刷新缓存** ```bash sudo yum clean all sudo rm -rf /var/cache/yum sudo yum makecache ``` #### 5. **验证软件包签名** ```bash # 测试单个软件包验证 sudo yum install --downloadonly mysql-community-server rpm --checksig mysql-community-server-*.rpm ``` 输出应包含 `gpg OK` 标识。 #### 6. **临时解决方案(不推荐)** ```bash # 禁用 GPG 检查(仅用于测试) sudo yum install --nogpgcheck mysql-community-server ``` ⚠️ 警告:这会降低系统安全性,仅作为临时措施[^3]。 #### 7. **完整修复流程 ```bash # 1. 清理旧配置 sudo yum remove mysql* sudo rm /etc/yum.repos.d/mysql-community*.repo # 2. 安装新版仓库 sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm # 3. 导入密钥 sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 # 4. 重新安装 sudo yum install mysql-community-server ``` ### 故障原因分析 1. **密钥过期**:MySQL 在 2022 年更换了 GPG 密钥[^1] 2. **仓库配置错误**:`gpgkey` 路径指向旧密钥文件 3. **缓存冲突**:yum 缓存了旧的签名信息 4. **版本不匹配**:服务器版本与密钥支持的版本不一致 > **重要提示**:MySQL 5.7 和 8.0 使用不同的仓库配置,确保选择正确的版本。安装后使用 `grep 'temporary password' /var/log/mysqld.log` 获取初始密码[^3]。
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宁海没有七号公园

谢谢你%%%

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值