问题描述:yum安装mysql时出现Public key for mysql-community-common-5.7.42-1.el7.x86_64.rpm is not installed告警,如下所示:
数据库:mysql 5.7.42
系统:rhel 7.3
1、问题重现
[root@leo-mysql-master ~]# yum install -y mysql-community-server
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
mysql-connectors-community                                                                                             | 2.6 kB  00:00:00     
mysql-tools-community                                                                                                  | 2.6 kB  00:00:00     
mysql57-community                                                                                                      | 2.6 kB  00:00:00     
(1/3): mysql-connectors-community/x86_64/primary_db                                                                    |  99 kB  00:00:00     
(2/3): mysql-tools-community/x86_64/primary_db                                                                         |  92 kB  00:00:00     
(3/3): mysql57-community/x86_64/primary_db                                                                             | 340 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.42-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.42-1.el7 for package: mysql-community-server-5.7.42-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.42-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.42-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.42-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.42-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.42-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.42-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                                      Arch                    Version                        Repository                          Size
==============================================================================================================================================
Installing:
 mysql-community-libs                         x86_64                  5.7.42-1.el7                   mysql57-community                  2.6 M
     replacing  mariadb-libs.x86_64 1:5.5.52-1.el7
 mysql-community-libs-compat                  x86_64                  5.7.42-1.el7                   mysql57-community                  1.2 M
     replacing  mariadb-libs.x86_64 1:5.5.52-1.el7
 mysql-community-server                       x86_64                  5.7.42-1.el7                   mysql57-community                  179 M
Installing for dependencies:
 mysql-community-client                       x86_64                  5.7.42-1.el7                   mysql57-community                   28 M
 mysql-community-common                       x86_64                  5.7.42-1.el7                   mysql57-community                  311 k

Transaction Summary
==============================================================================================================================================
Install  3 Packages (+2 Dependent packages)

Total download size: 211 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/mysql57-community/packages/mysql-community-common-5.7.42-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Public key for mysql-community-common-5.7.42-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-5.7.42-1.el7.x86_64.rpm                                                                  | 311 kB  00:00:00     
(2/5): mysql-community-libs-5.7.42-1.el7.x86_64.rpm                                                                    | 2.6 MB  00:00:01     
(3/5): mysql-community-libs-compat-5.7.42-1.el7.x86_64.rpm                                                             | 1.2 MB  00:00:00     
(4/5): mysql-community-client-5.7.42-1.el7.x86_64.rpm                                                                  |  28 MB  00:00:05     
(5/5): mysql-community-server-5.7.42-1.el7.x86_64.rpm                                                                                                                                                             | 179 MB  00:00:25     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                    7.6 MB/s | 211 MB  00:00:27     
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    : mysql57-community-release-el7-8.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


Public key for mysql-community-common-5.7.42-1.el7.x86_64.rpm is not installed


 Failing package is: mysql-community-common-5.7.42-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

2、异常原因
由于MySQL GPG密匙过期导致.

3、解决方案
--在安装mysql之前导入2022年密匙.
[root@leo-mysql-master ~]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
--重新安装
[root@leo-mysql-master ~]# yum install -y mysql-community-server                     
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.42-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.42-1.el7 for package: mysql-community-server-5.7.42-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.42-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.42-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.42-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.42-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.42-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.42-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                                      Arch                    Version                        Repository                          Size
==============================================================================================================================================
Installing:
 mysql-community-libs                         x86_64                  5.7.42-1.el7                   mysql57-community                  2.6 M
     replacing  mariadb-libs.x86_64 1:5.5.52-1.el7
 mysql-community-libs-compat                  x86_64                  5.7.42-1.el7                   mysql57-community                  1.2 M
     replacing  mariadb-libs.x86_64 1:5.5.52-1.el7
 mysql-community-server                       x86_64                  5.7.42-1.el7                   mysql57-community                  179 M
Installing for dependencies:
 mysql-community-client                       x86_64                  5.7.42-1.el7                   mysql57-community                   28 M
 mysql-community-common                       x86_64                  5.7.42-1.el7                   mysql57-community                  311 k

Transaction Summary
==============================================================================================================================================
Install  3 Packages (+2 Dependent packages)

Total size: 211 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-5.7.42-1.el7.x86_64                                                                                 1/6 
  Installing : mysql-community-libs-5.7.42-1.el7.x86_64                                                                                   2/6 
  Installing : mysql-community-client-5.7.42-1.el7.x86_64                                                                                 3/6 
  Installing : mysql-community-server-5.7.42-1.el7.x86_64                                                                                 4/6 
  Installing : mysql-community-libs-compat-5.7.42-1.el7.x86_64                                                                            5/6 
  Erasing    : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                         6/6 
  Verifying  : mysql-community-common-5.7.42-1.el7.x86_64                                                                                 1/6 
  Verifying  : mysql-community-libs-compat-5.7.42-1.el7.x86_64                                                                            2/6 
  Verifying  : mysql-community-libs-5.7.42-1.el7.x86_64                                                                                   3/6 
  Verifying  : mysql-community-client-5.7.42-1.el7.x86_64                                                                                 4/6 
  Verifying  : mysql-community-server-5.7.42-1.el7.x86_64                                                                                 5/6 
  Verifying  : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                         6/6 

Installed:
  mysql-community-libs.x86_64 0:5.7.42-1.el7  mysql-community-libs-compat.x86_64 0:5.7.42-1.el7  mysql-community-server.x86_64 0:5.7.42-1.el7 

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.42-1.el7                          mysql-community-common.x86_64 0:5.7.42-1.el7                         

Replaced:
  mariadb-libs.x86_64 1:5.5.52-1.el7                                                                                                          

Complete!

说明:如上所示,无异常告警.

参考文档:https://blog.csdn.net/weixin_44049210/article/details/129134782