今天在Centos7上按以前的方法通过yum安装MySQL时候碰到一个诡异的问题,报错如下
[root@ecs ~]# yum -y install mysql-community-server
Loaded plugins: fastestmirror, versionlock
Determining fastest mirrors
* base: mirrors.cn99.com
* extras: mirrors.163.com
* updates: mirrors.ustc.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
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
updates | 2.9 kB 00:00:00
(1/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/7): extras/7/x86_64/primary_db | 246 kB 00:00:00
(3/7): mysql-connectors-community/x86_64/primary_db | 90 kB 00:00:00
(4/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(5/7): mysql57-community/x86_64/primary_db | 298 kB 00:00:00
(6/7): updates/7/x86_64/primary_db | 14 MB 00:00:01
(7/7): mysql-tools-community/x86_64/primary_db | 94 kB 00:00:05
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.37-1.el7 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.37-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.37-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.37-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.37-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.37-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.37-1.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.37-1.el7 mysql57-community 2.4 M
replacing mariadb-libs.x86_64 1:5.5.68-1.el7
mysql-community-libs-compat x86_64 5.7.37-1.el7 mysql57-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.68-1.el7
mysql-community-server x86_64 5.7.37-1.el7 mysql57-community 174 M
Installing for dependencies:
mysql-community-client x86_64 5.7.37-1.el7 mysql57-community 25 M
mysql-community-common x86_64 5.7.37-1.el7 mysql57-community 311 k
Transaction Summary
==========================================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Total download size: 203 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY | 760 kB 00:21:11 ETA
Public key for mysql-community-common-5.7.37-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-5.7.37-1.el7.x86_64.rpm | 311 kB 00:00:02
(2/5): mysql-community-libs-5.7.37-1.el7.x86_64.rpm | 2.4 MB 00:00:08
(3/5): mysql-community-client-5.7.37-1.el7.x86_64.rpm | 25 MB 00:00:17
(4/5): mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm | 1.2 MB 00:00:06
(5/5): mysql-community-server-5.7.37-1.el7.x86_64.rpm | 174 MB 00:01:15
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.2 MB/s | 203 MB 00:01:32
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-11.noarch (@/mysql57-community-release-el7-11.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Public key for mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm is not installed
Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
不论是MySQL5.7还是8.0的版本均出现这个问题,百度找了一圈依旧没有解决办法。最后还是Google解决了我的问题。
解决办法:rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
参考:MySQL GPG keys expired, preventing installation/upgrade of MySQL packages from the official repository.