1.查看mysql安装的包
[root@localhost ~]# rpm -qa | grep -i mysql
mysql-community-devel-5.6.48-2.el7.x86_64
mysql-community-common-5.6.48-2.el7.x86_64
mysql-community-client-5.6.48-2.el7.x86_64
mysql-community-release-el7-5.noarch
mysql-community-libs-5.6.48-2.el7.x86_64
mysql-community-server-5.6.48-2.el7.x86_64
2.关闭MySQL服务
service mysqld stop
3.删除安装的包
rpm -ev --nodeps mysql-community-devel-5.6.48-2.el7.x86_64
rpm -ev --nodeps mysql-community-common-5.6.48-2.el7.x86_64
rpm -ev --nodeps mysql-community-client-5.6.48-2.el7.x86_64
rpm -ev --nodeps mysql-community-release-el7-5.noarch
rpm -ev --nodeps mysql-community-libs-5.6.48-2.el7.x86_64
rpm -ev --nodeps mysql-community-server-5.6.48-2.el7.x86_64
4.查找残余的文件
find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
/usr/share/mysql
再删除
rm -rf /etc/selinux/targeted/active/modules/100/mysql
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/share/mysql
5.再看下/etc/my.cnf还有没有,有的话就删掉
也有可能会再卸载的时候生成/etc/my.cnf.rpmsave 文件,也删掉就行了