一、卸载已安装的MySQL包
1、查找以下安装包
**使用命令 yum list installed | grep mysql**
[root@localhost7 ~]# yum list installed | grep mysql
mysql-community-client.x86_64 5.7.31-1.el7 @mysql57-community
mysql-community-common.x86_64 5.7.31-1.el7 @mysql57-community
mysql-community-libs.x86_64 5.7.31-1.el7 @mysql57-community
mysql-community-libs-compat.x86_64 5.7.31-1.el7 @mysql57-community
mysql-community-server.x86_64 5.7.31-1.el7 @mysql57-community
mysql57-community-release.noarch el7-11 @/mysql57-community-release-el7-11.noarch
**或者用以下命令查找 rpm -qa|grep mysql**
[root@localhost7 ~]# rpm -qa|grep mysql
mysql-community-server-5.7.31-1.el7.x86_64
mysql-community-common-5.7.31-1.el7.x86_64
mysql-community-client-5.7.31-1.el7.x86_64
mysql57-community-release-el7-11.noarch
mysql-community-libs-compat-5.7.31-1.el7.x86_64
mysql-community-libs-5.7.31-1.el7.x86_64
2、将前面的6个安装包都删除
[root@localhost7 ~]# yum remove xxxxxxx
或者
[root@localhost7 ~]# rpm -e --nodeps xxxxxxx
xxxxx是前面的安装包名,--nodeps是强制删除。
3、查找mysql残留文件夹,并删除
[root@localhost7 ~]# find / -name mysql
/etc/logrotate.d/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/bin/mysql
/usr/lib64/mysql
/usr/share/mysql
删除 (请勿删错,谨慎操作!)
rm-rf xxxxxx