----------------------------------------------------------------卸载mysql8
参考文章:https://blog.csdn.net/weixin_40896800/article/details/90490193
1. 关闭 mysql 服务
systemctl stop mysqld.service
2. 查看当前 mysql 安装状况
rpm -qa | grep -i mysql 或 yum list installed | grep mysql
3. 卸载上述命令查询出的已安装程序
yum remove mysql-a mysql-b mysql-c mysqk-d
务必卸载干净,反复执行 rpm -qa | grep -i mysql 确认是否有卸载残留
4. 删除 mysql 相关文件
查找相关文件
find / -name mysql
删除上述命令查找出的相关文件
rm -rf xxx
删除 my.cnf
rm -rf /etc/my.cnf
5. 下载 yum 源文件并安装
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
6. 查看有哪些版本的 mysql
yum repolist all | grep mysql
7. 确认启用版本无误后,执行安装
yum install -y mysql-community-server
8. 其它
剩下的操作基本和 mysql8 一样,需要注意的是 mysql5.7 貌似只能 root@localhost 账户本地对其它账户做授权(自建的账户、授予了 all privileges 权限、远程登录,无法给其它账户授权,具体待验证)
---------------------------------------------centos7直接安装替换mariadb :
# 下载并安装MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
# 使用上面的命令就直接下载了安装用的Yum Repository,大概25KB的样子,然后就可以直接yum安装了。
yum -y install mysql57-community-release-el7-10.noarch.rpm
# 开始安装MySQL服务器。
yum -y install mysql-community-server # 这步可能会花些时间,安装完成后就会覆盖掉之前的mariadb。
# 首先启动MySQL
systemctl start mysqld.service
# 查看初始密码
grep "password" /var/log/mysqld.log
# 进入mysql
mysql -uroot -p
输入password
# 需要先修改root密码
法一:
alter user 'root'@'localhost' identified by 'cy7m0ypu8CpLFperzI45';
法二:
set password for 'root'@'localhost'=password('cy7m0ypu8CpLFperzI45');
法三:
update mysql.user set authentication_string=password('cy7m0ypu8CpLFperzI45') where user='root' and Host = 'localhost';
# 记得最后要刷新权限
flush privileges;
D 如果根分区比较小 建议修改数据库存放位置至 /home下:
参考: https://blog.csdn.net/zyw_java/article/details/78512285
有坑参考:https://blog.csdn.net/yuezhilangniao/article/details/111029160