1. 程式人生 > >linux環境徹底刪除mysql步驟

linux環境徹底刪除mysql步驟

1,使用命令檢視mysql的安裝情況

rpm -qa | grep mysql

結果:

[[email protected] ~]# rpm -qa | grep mysql
mysql-community-common-5.7.24-1.el7.x86_64
mysql-community-libs-5.7.24-1.el7.x86_64
mysql-community-client-5.7.24-1.el7.x86_64
mysql57-community-release-el7-9.noarch
mysql-community-server-5.7.24-1.el7.x86_64

2,停止mysql服務,刪除所安裝的mysql服務

rpm -e --nodeps mysql服務名稱(上面命令查詢的服務),如:
rpm -e --nodeps mysql-community-common-5.7.24-1.el7.x86_64
rpm -e --nodeps mysql-community-libs-5.7.24-1.el7.x86_64
rpm -e --nodeps mysql-community-client-5.7.24-1.el7.x86_64
rpm -e --nodeps mysql57-community-release-el7-9.noarch
rpm -e --nodeps mysql-community-server-5.7.24-1.el7.x86_64

3,查詢mysql的目錄和庫檔案,並刪除

[[email protected] ~]# find / -name mysql 
/var/lib/mysql
/var/lib/mysql/mysql
/etc/logrotate.d/mysql
/usr/lib64/mysql
/usr/share/mysql
/usr/bin/mysql

刪除對應的mysql目錄

rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql
rm -rf /etc/logrotate.d/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/share/mysql
rm -rf /usr/bin/mysql

注意:解除安裝後/etc/my.cnf不會刪除,需要進行手工刪除

rm -rf /etc/my.cnf 

4,再次查詢mysql的安裝情況

rpm -qa | grep mysql

無結果,說明已經解除安裝乾淨,接下來直接安裝mysql就可以了