對于在Linux下通過rpm方式安裝的mysql,我們可以通過移除這些rpm包以及刪除項(xiàng)目的目錄來達(dá)到卸載的目的。本文演示了在SUSE Linux 10下卸載MySQL 5.5.37。具體見下文。
1、環(huán)境
代碼如下:
#OS環(huán)境
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服務(wù)
代碼如下:
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、移除相關(guān)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,也做相應(yīng)移除
根據(jù)需要考慮是否移除linux下的mysql 用戶
代碼如下:
SZDB:~ # cat /etc/passwd | grep mysql
mysql:x:104:106:MySQL server:/var/lib/mysql:/bin/bash
5、校驗(yàn)結(jié)果
代碼如下:
SZDB:~ # rpm -qa | grep -i mysql
SZDB:~ # chkconfig --list |grep mysql
更多信息請查看IT技術(shù)專欄