linux下mysql卸载

1. 查找安装的mysql包

[root@root ~]# rpm -qa|grep -i mysql
mysql-community-libs-compat-5.6.24-3.el6.x86_64
mysql-community-libs-5.6.24-3.el6.x86_64
mysql-community-server-5.6.24-3.el6.x86_64
mysql-community-common-5.6.24-3.el6.x86_64
mysql-community-client-5.6.24-3.el6.x86_64

2. 停止mysql服务器删除mysql

[root@root ~]# sudo service mysqld stop
Stopping mysqld:  [  OK  ]
[root@root ~]# rpm -ev mysql-community-server-5.6.24-3.el6.x86_64
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
[root@root ~]# rpm -ev mysql-community-client-5.6.24-3.el6.x86_64

自带mysql包使用下面命令卸载

[root@root ~]# rpm -ev –nodeps mysql-community-libs-compat-5.6.24-3.el6.x86_64
[root@root ~]# rpm -ev –nodeps mysql-community-libs-5.6.24-3.el6.x86_64
[root@root ~]# rpm -ev –nodeps mysql-community-common-5.6.24-3.el6.x86_64

[root@root ~]# rpm -qa|grep -i mysql
[root@root ~]#

3. 查找mysql目录,并且删除mysql的文件和库

[root@root ~]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/share/mysql
[root@root ~]#
[root@root ~]# rm -rf /var/lib/mysql
[root@root ~]# rm -rf /usr/share/mysql

删除my.cnf 文件,删除mysql-community-server已将my.cnf改名为my.cnf.rpmsave
[root@root etc]# ls my.cnf*
my.cnf.rpmsave
[root@root etc]# rm -rf /etc/my.cnf.rpmsave