安装wget命令
[root@localhost mysql]# yum -y install wget
在线下载mysql安装包
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装MySQL
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
安装mysql服务
cd /etc/yum.repos.d/
yum -y install mysql-server
遇到以下问题
源 "MySQL 5.7 Community Server" 的 GPG 密钥已安装,但是不适用于此软件包。请检查源的公钥 URL 是否配置正确。
输入
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
再重新安装,成功
启动MySQL
systemctl start mysqld
修改MySQL临时密码
获取MySQL临时密码,为 9w/aeaXuNoJ*
grep 'temporary password' /var/log/mysqld.log
使用临时密码先登录
mysql -uroot -p9w/aeaXuNoJ*
输入以下几句命令
set global validate_password_policy=LOW;
set global validate_password_length=4;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
禁用防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.servic