卸载mysql的时候先把mysql服务停止。
[root@localhost mysql]# service mysql stop
查找mysql安装文件的相关目录
[root@localhost ~]# whereis mysql
mysql: /usr/lib64/mysql /usr/local/mysql /usr/share/mysql /usr/local/mysql/bin/mysql
[root@localhost ~]# find / -name mysql
/etc/rc.d/init.d/mysql
/etc/selinux/targeted/active/modules/100/mysql
/root/hbk/mysql-5.6.33-linux-glibc2.5-x86_64/bin/mysql
/root/hbk/mysql-5.6.33-linux-glibc2.5-x86_64/include/mysql
/var/spool/mail/mysql
/usr/lib64/mysql
/usr/share/mysql
/usr/local/mysql
/usr/local/mysql/data/mysql
/usr/local/mysql/data/mysql/mysql
/usr/local/mysql/bin/mysql
/usr/local/mysql/include/mysql
/home/mysql
删除所有相关文件
[root@localhost ~]# rm -rf /root/hbk/mysql-5.6.33-linux-glibc2.5-x86_64/
[root@localhost local]# rm -rf /usr/local/mysql/
[root@localhost local]# rm -rf /var/spool/mail/mysql
[root@localhost home]# rm -rf /home/mysql
[root@localhost home]# rm -rf /etc/rc.d/init.d/mysql
[root@localhost etc]# find / -name mysql
剩下这些即可(我发现如果删除了,虚拟机会莫名的报错)
[root@localhost ~]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/usr/lib64/mysql
/usr/share/mysql
删除配置文件my.cnf
[root@localhost etc]# rm -rf /etc/my.cnf
删除mysql用户及组
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
[root@localhost etc]# userdel mysql