(1)检查是否安装了MySQL组件
[root@DB-Server init.d]# rpm -qa | grep -i mysql
MySQL-devel-5.6.23-1.linux_glibc2.5
MySQL-client-5.6.23-1.linux_glibc2.5
MySQL-server-5.6.23-1.linux_glibc2.5
(2)卸载前关闭MySQL服务
[root@DB-Server init.d]# service mysql status
MySQL running (25673)[ OK ]
[root@DB-Server init.d]# service mysql stop
Shutting down MySQL..[ OK ]
[root@DB-Server init.d]# service mysql status
MySQL is not running[FAILED]
(3)收集MySQL对应的文件夹信息
[root@DB-Server init.d]# find / -name mysql
/etc/rc.d/init.d/mysql
/etc/logrotate.d/mysql
/var/lock/subsys/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/include/mysql
/usr/include/mysql/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/lib64/mysql
(4)卸载删除MySQL各类组件
[root@DB-Server init.d]# rpm -ev MySQL-devel-5.6.23-1.linux_glibc2.5
[root@DB-Server init.d]# rpm -ev MySQL-server-5.6.23-1.linux_glibc2.5
You have new mail in /var/spool/mail/root
[root@DB-Server init.d]# rpm -ev MySQL-client-5.6.23-1.linux_glibc2.5
备注:
问题现象:如果在卸载的过程中,无法卸载,并报错:error: Failed dependencies:
mysql = 5.1.73-5.el6_6 is needed by (installed) mysql-server-5.1.73-5.el6_6.x86_64
原因:有依赖包
解决办法:加参数--nodeps
例如原来删除命令:rpm -ev MySQL-client-5.6.23-1.linux_glibc2.5
修改后删除命令:rpm -ev MySQL-client-5.6.23-1.linux_glibc2.5 --nodeps
(5)删除MySQL对应的文件夹
[root@DB-Server init.d]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
[root@DB-Server init.d]# rm -rf /var/lib/mysql
[root@DB-Server init.d]# rm -rf /var/lib/mysql/mysql
[root@DB-Server init.d]# rm -rf /usr/lib64/mysql
(6)删除mysql用户及用户组
如果有必要,删除mysql用户以及mysql用户组。
[root@DB-Server ~]# more /etc/passwd | grep mysql
mysql:x:101:501::/home/mysql:/bin/bash
[root@DB-Server ~]# more /etc/shadow | grep mysql
mysql:!!:16496::::::
[root@DB-Server ~]# more /etc/group | grep mysql
mysql:x:501:
[root@DB-Server ~]# userdel mysql
[root@DB-Server ~]# groupdel mysql
groupdel: group mysql does not exist
[root@DB-Server ~]#
(7)确认MySQL是否卸载删除
[root@DB-Server init.d]# rpm -qa | grep -i mysql