centos7 使用rpm二进制包安装mysql5.7

centos7系统默认的yum源自带的mysql数据库版本为mariadb5.5.68,因业务需要使用mysql5.7版本,可通过以下步骤使用rpm二进制包方式安装:

移除系统自带 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初始密码

alter user 'root'@'localhost' identified with mysql_native_password by 'password';
原文地址:https://www.cnblogs.com/eddie1127/p/15628323.html