天天看点

centos下yum方式安装mysql5.7,Error: GPG check FAILED与Unable to find a match: mysql-community-server

环境:

系统:centos8

软件:mysql 5.7

安装方式:yum安装

1、配置mysql 5.7的yum源

wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm      

然后查看一下是否配置上:

yum repolist 查看已配置的yum源

[root@python01 ~]# yum repolist 
repo id                                                                             repo name
AppStream                                                                           CentOS-8-stream - AppStream - mirrors.aliyun.com
base                                                                                CentOS-8-stream - Base - mirrors.aliyun.com
extras                                                                              CentOS-8-stream - Extras - mirrors.aliyun.com
mysql-connectors-community                                                          MySQL Connectors Community
mysql-tools-community                                                               MySQL Tools Community
mysql57-community                                                                   MySQL 5.7 Community Server      

2.1、yum安装mysql

yum -y install mysql-community-server      

报错1:

Error: Unable to find a match: mysql-community-server      

先关闭一下mysql模块,再继续执行yum install安装:

yum module disable mysql      

报错2:

这是gpg验证不通过的原因,因为我是在centos8系统上安装mysql57-community-release-el7-10.noarch.rpm,即el7本身应该在centos7上安装的,但是5.7没有el8的包,如果安装mysql80-community-release-el8-4.noarch.rpm,就没有这个问题;

mysql 8.0 release下载地址:​​https://dev.mysql.com/downloads/repo/yum/​​

Error: GPG check FAILED      

跳过gpg验证即可:

yum -y install mysql-community-server --nogpgcheck      

报错3:GPG key到期

The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.      

更新GPG key

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

2.2、启动mysql:

[root@python01 ~]# systemctl start mysqld.service 
[root@python01 ~]# ps -ef|grep mysql              
mysql     336231       1 17 13:30 ?        00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid      
grep "password" /var/log/mysqld.log
mysql -uroot -p      
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';