Linux 下卸載MySQL 5

來源:互聯網
上載者:User

    對於在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方式)

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.