1. 获取rpm
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2. 安装rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
3. 确认依赖文件
cd /etc/yum.repos.d
ls
查看该文件夹下是否已存在如下两个文件
4. import mysql 的公钥到RPM的配置中
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
5. 在 /etc/yum.repos.d 下执行安装
yum install mysql-server
6. 获取安装时的临时密码
grep 'temporary password' /var/log/mysqld.log
7. 登录数据库
mysql -u root -p
8. 修改同级强度密码
alter user 'root'@'localhost' identified by 'Root@123456';
9. 修改密码强度策略
set global validate_password_policy=0;
set global validate_password_length=4;
flush privileges;
10. 更新超管密码
alter user 'root'@'localhost' identified by 'root';
11. 可远程连接配置
show databases;
use mysql;
show tables;
update user set Host='%' where User='root';
flush privileges;
12. 配置默认编码
vi /etc/my.cnf
#添加
character_set_server=utf8
init_connect=‘SET NAMES utf8’
13. 重启
systemctl restart mysqld
14. 开机自启
systemctl enable mysqld