centos安装MySQL5.7报错Check that the correct key URLs are configured for this repository.

说明:安装MySQL5.7时遇到的一个小问题,记录一下解决过程和思路。

步骤1:安装MySQL 5.7

首先,在服务器上安装MySQL 5.7。

添加MySQL Yum存储库:

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm

安装MySQL:

sudo yum install mysql-server

安装报错

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-server-5.7.44-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 解决思路:因为是新机器一开始以为是yum源的问题,更换了阿里云的yum源,后面证明无效。

然后尝试从MySQL官网下载密钥,覆盖机器上面的密钥,问题解决,过程如下:

步骤2:删除现有的GPG密钥

首先,删除现有的MySQL GPG密钥:

sudo rpm -e gpg-pubkey-3a79bd29

步骤3:重新导入MySQL GPG密钥

导入正确的MySQL GPG密钥。请使用以下命令:

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

步骤4:检查并更新Yum仓库配置

确保 /etc/yum.repos.d/mysql-community.repo 文件中正确配置了GPG密钥URL。

编辑MySQL社区仓库配置文件:

sudo vim /etc/yum.repos.d/mysql-community.repo

找到gpgkey的路径,将RPM-GPG-KEY-mysql文件备份替换

 

mv RPM-GPG-KEY-mysql RPM-GPG-KEY-mysql.bak
#添加官网下载的密钥,链接https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
#将密钥复制粘贴到RPM-GPG-KEY-mysql中
vim RPM-GPG-KEY-mysql

步骤5:清理Yum缓存并重试安装

清理Yum缓存以确保使用最新的元数据:

sudo yum clean all
sudo yum makecache

尝试重新安装MySQL:

sudo yum install mysql-community-server

 安装成功,问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值