Retrieving key from RPM-GPG-KEY-mysql

安装mysql8时提示:

Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-libs-compat-8.0.31-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 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-libs-compat-8.0.31-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

原因是Key的问题,重新导入Key。

1、导入Keysudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

过后再安装,还是失败。

2、在线导入Keysudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

然后再安装,结果成功。