移除系统自带 Mariadb组件,避免版本组件冲突

rpm -qa |grep mariadb
yum remove mariadb-libs-5.5.68-1.el7.x86_64
在清华大学镜像源下载rpm包

wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-common-5.7.36-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-server-5.7.36-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-client-5.7.36-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-libs-5.7.36-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
依次yum安装,注意先后顺序

yum install mysql-community-common-5.7.36-1.el7.x86_64.rpm
yum install mysql-community-libs-5.7.36-1.el7.x86_64.rpm
yum install mysql-community-client-5.7.36-1.el7.x86_64.rpm
yum install mysql-community-server-5.7.36-1.el7.x86_64.rpm
yum install mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
启动mysql服务

systemctl start mysqld.service
systemctl enable mysqld.service
mysql5.7第一次登陆要求修改root密码
查看初始密码

grep "password" /var/log/mysqld.log
修改root初始密码
mysql -uroot -p'mWB/CJLkS8af'
alter user 'root'@'localhost' identified with mysql_native_password by 'PassWord_123.';
CREATE DATABASE my_database DEFAULT CHARACTER SET utf8mb4;
create user 'username'@'localhost' identified by 'Password_123.';
grant all on dataname.* to 'username'@'localhost';

切换用户导入数据库
use database
source /xxx/xxx.sql

最后修改:2024 年 03 月 20 日
如果觉得我的文章对你有用,请随意赞赏