1、官网下载MySQL安装包:https://dev.mysql.com/downloads/mysql/
我选的Archives,下载5.7版本,此处根据自己需要下载即可
2、解压:
tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar

3、安装前先卸载卸载自带的mariadb-lib
yum remove mysql-libs

4、安装MySQL
rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm

5、数据库初始化
mysqld --initialize --user=mysql
6、启动MySQL服务
systemctl start mysqld.service
7、登录MySQL
#查看root密码 cat /var/log/mysqld.log |grep password

#修改root密码
set password=password('123456');
8、远程访问下MySQL
9、允许root远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
#重启MySQL服务
systemctl restart mysqld

再用远程访问连接下MySQL,成功了!