首页 > 代码库 > Linux 下卸载MySQL 5
Linux 下卸载MySQL 5
对于在Linux下通过rpm方式的mysql,我们可以通过移除这些rpm包以及删除项目的目录来达到卸载的目的。本文演示了在SUSE Linux 10下下载MySQL 5.5.37。具体见下文。
1、环境
#OS环境
SZDB:~ # cat /etc/issue
Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel \r (\l).
#查看已安装的安装包
SZDB:~ # rpm -qa | grep -i mysql
MySQL-devel-5.5.37-1.sles10
MySQL-server-5.5.37-1.sles10
MySQL-shared-compat-5.5.37-1.sles10
MySQL-client-5.5.37-1.sles10
MySQL-shared-5.5.37-1.sles10
MySQL-test-5.5.37-1.sles10
MySQL-embedded-5.5.37-1.sles10
2、停止mysql服务
SZDB:~ # /etc/init.d/mysql stop
Shutting down MySQL. done
3、使用rpm卸载mysql
SZDB:~ # rpm -e --nodeps MySQL-server-5.5.37-1.sles10
insserv: script postgresqlMemory: service postgresql already provided!
insserv: script postgresql: service postgresql already provided!
mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
#使用下面的方式移除所有mysql rpm包
SZDB:~ # rpm -e --nodeps MySQL-client-5.5.37-1.sles10
SZDB:~ # rpm -e --nodeps MySQL-devel-5.5.37-1.sles10
SZDB:~ # rpm -e --nodeps MySQL-shared-compat-5.5.37-1.sles10
SZDB:~ # rpm -e --nodeps MySQL-shared-5.5.37-1.sles10
SZDB:~ # rpm -e --nodeps MySQL-test-5.5.37-1.sles10
SZDB:~ # rpm -e --nodeps MySQL-embedded-5.5.37-1.sles10
4、移除相关mysql目录及文件
SZDB:~ # find / -name mysql
/etc/apparmor.d/abstractions/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
/usr/local/quickfix_old/src/sql/mysql
SZDB:~ # rm -rf /etc/apparmor.d/abstractions/mysql
SZDB:~ # rm -rf /var/lib/mysql
SZDB:~ # rm -rf /var/lib/mysql/mysql
SZDB:~ # rm -rf /usr/lib64/mysql
SZDB:~ # rm -rf /usr/local/quickfix_old/src/sql/mysql
SZDB:~ # ls /etc/my*
/bin/ls: /etc/my*: No such file or directory
注,如果/etc目录下有my.cnf,也做相应移除
根据需要考虑是否移除linux下的mysql 用户
SZDB:~ # cat /etc/passwd | grep mysql
mysql:x:104:106:MySQL server:/var/lib/mysql:/bin/bash
5、校验结果
SZDB:~ # rpm -qa | grep -i mysql
SZDB:~ # chkconfig --list |grep mysql
有关Linux下安装MySQL可参考:
Linux 5 下安装MySQL 5.6(RPM方式)