1.安装mysql
wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

rpm -Uvh mysql57-community-release-el6-9.noarch.rpm

#在这里遇到执行yum install mysql-community-server查询不到
解决方式:
yum module disable mysql

yum install mysql-community-server

#在这里又遇到了新的问题

错误:
 问题: cannot install the best candidate for the job
  - nothing provides libsasl2.so.2()(64bit) needed by mysql-community-server-5.7.35-1.el6.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用软件包的最佳候选)

解决方式:
vi /etc/yum.repos.d/mysql-community.repo

修改: 
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

继续执行:
yum install mysql-community-server

2.启动mysql服务

systemctl start mysqld

3.设置开机自启

systemctl enable mysqld

systemctl daemon-reload

4.查询初始密码

vim /var/log/mysqld.log

5.开启远程访问权限

use mysql;

update user set host = '%' where user= 'root'

flush privileges;

#查看防火墙状态
systemctl status firewalld

#添加mysql端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent

#刷新mysql防火墙
firewall-cmd --reload

6.修改密码

修改密码策略:
SHOW VARIABLES LIKE 'validate_password%';

首先需要设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW 即可,
set global validate_password_policy=LOW;
set global validate_password_length=6;

ALTER USER 'root'@'%' IDENTIFIED BY '123456';

FLUSH PRIVILEGES;

7.修改配置

# 支持时间为0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# 不区分大小写
lower_case_table_names=1

8.修改报错

Host 'xxxxxxx' is blocked because of many connection errors; unblock with 'mysqlad
show global variables like '%max_connect_errors%';

set global max_connect_errors=1000;