先查看下,把MySQL停下来
查看进程状态
ps -ef | grep mysql
查看mysql服务状态
service mysqld status
停止mysql服务
service mysqld stop
检查是否安装MySQL
[[email protected] ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.73-8.el6_8.x86_64
[[email protected] ~]# rpm -e mysql-libs-5.1.73-8.el6_8.x86_64
error: Failed dependencies:
libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-8.el6.x86_64
libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-8.el6.x86_64
mysql-libs is needed by (installed) postfix-2:2.6.6-8.el6.x86_64
[[email protected] ~]# rpm -e –nodeps mysql-libs-5.1.73-8.el6_8.x86_64
rpm -e –nodeps 包名
如果提示依赖包错误,则使用以下命令尝试
rpm -ev mysql-libs-5.1.73-8.el6_8.x86_64 --nodeps
如果提示错误:error: %preun(xxxxxx) scriptlet failed, exit status 1
则用以下命令尝试 rpm -e --noscripts mysql-libs-5.1.73-8.el6_8.x86_64
查找MySQL的安装目录并彻底删除
[[email protected] ~]# find / -name mysql
/var/spool/mail/mysql
/usr/local/include/mysql
/usr/local/mysql
/usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/include/mysql
/usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/bin/mysql
/opt/data/mysql
[[email protected] ~]# rm -Rf /var/spool/mail/mysql /usr/local/include/mysql /usr/local/mysql /opt/data/mysql /usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/
删除一些配置文件
配置文件一般有/etc/my.cnf 或/etc/init.d/mysql.server
[[email protected] ~]# rm -rf /etc/my.cnf
删除MySQL用户以及用户组
[[email protected] ~]# userdel mysql
[[email protected] ~]# id mysql
id: mysql: No such user
检查一遍mysql 是否成功删除
rpm -qa|grep -i mysql