参考:

https://blog.csdn.net/qq_37130607/article/details/105854301


卸载原来的MySQL


rpm -qa |grep mysql


如果返回有内容,就依次使用命令卸载:



rpm -e 软件包名称


如果没有返回内容,则进入下一步。



下载mysql的rpm


wget http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm


安装mysql的rpm



rpm -ivh mysql80-community-release-el7-3.noarch.rpm

这时候会在 /etc/yum.repos.d/目录下生成两个文件

mysql-community.repo和mysql-community-source.repo



修改repo文件(安装5.7,不要8.0)


cd /etc/yum.repos.d/
vi mysql-community.repo

将 [mysql57-community] 下的 enabled 设置为1,表示打开5.7

将 [mysql80-community] 下的 enabled 设置为0,表示关闭8.0

修改完,:wq 保存退出

安装Mysql



yum -y install mysql-community-server

查看Mysql版本



mysql --version

启动Mysql并查看Mysql状态



systemctl start mysqld.service
systemctl status mysqld.service


获取临时密码



grep "password" /var/log/mysqld.log


遇到问题1:



No match for argument: mysql-community
错误:没有任何匹配: mysql-community

问题2:

错误:Transaction test error:   file /etc/my.cnf from install of mysql-community-server-5.7.34-1.el7.x86_64 conflicts with file from package mariadb-connector-c-config-3.1.11-2.el8_3.noarch

解决方法:



[#zeyu#]

问题1:

1、运行命令


yum module disable mysql


2、再次运行




yum -y install mysql-community-server


问题2:

yum -y remove mariadb-connector*

再次重试

成功安装。


[/#zeyu#]