環境:
系統: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';