1.下载mysql安装包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.44-1.el7.x86_64.rpm-bundle.tar
2.解压安装包
tar -xvf mysql-5.7.44-1.el7.x86_64.rpm-bundle.tar
3. 解决冲突
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
4. vi /etc/sysconfig/selinux
SELINUX=enforcing 修改为SELINUX=disabled
5.setenforce 0
6.iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
7.安装mysql
rpm -ivh mysql-community-common-5.7.44-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.44-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.44-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.44-1.el7.x86_64.rpm --force --nodeps
8.修改 /etc/my.cnf 文件
lower_case_table_names=1 #数据库不区分大小写
datadir=/data/mysql/database #指定数据库目录
9.启动mysql
systemctl start mysqld.service
10.获取用户密码
grep 'temporary password' /var/log/mysqld.log
11.连接mysql后修改用户密码
alter user 'root'@'localhost' identified by 'Rjtx@1234';
12.修改用户host
use mysql;
update user set Host ='%' where User ='root';
flush privileges;