Detailed explanation of clean uninstall mysql under Linux

1. Use the following command to view the current installation of mysql

[plain]  view plain copy  
  1. rpm -qa|grep -i mysql  

You can see as shown in the following figure:


It shows that it was installed before:
MySQL-client-5.5.25a-1.rhel5
MySQL-server-5.5.25a-1.rhel5


2. Stop the mysql service and delete the previously installed mysql

Delete command: rpm -e –nodeps package name
[plain]  view plain copy  
  1. rpm -ev MySQL-client-5.5.25a-1.rhel5  
  2. rpm -ev MySQL-server-5.5.25a-1.rhel5  
If it prompts a dependency package error, use the following command to try

[plain]  view plain copy  
  1. rpm -ev MySQL-client-5.5.25a-1.rhel5 --nodeps  

If it prompts an error: error: %preun(xxxxxx) scriptlet failed, exit status 1

Then try with the following command:

[plain]  view plain copy  
  1. rpm -e --noscripts MySQL-client-5.5.25a-1.rhel5  

3. Find the directory of the previous version of mysql, and delete the files and libraries of the old version of mysql

find / -name mysql
The search results are as follows:
[plain]  view plain copy  
  1. find / -name mysql  

/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
delete the corresponding mysql directory
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64 /mysql
find the directory and delete it


Note: /etc/my.cnf will not be deleted after uninstallation, it needs to be deleted manually
 
[plain]  view plain copy  
  1. rm -rf /etc/my.cnf  

4. Find out if mysql is installed on the machine again
[plain]  view plain copy  
  1. rpm -qa|grep -i mysql  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325420573&siteId=291194637