Foreword:
mysql database is very commonly used, but sometimes different versions of upgrades, software upgrades, and different installation methods will be uninstalled. Unclean uninstallation will cause problems with the new version. Today I will talk about the complete clean uninstallation of mysql under Linux.
1. View the installation of mysql
rpm -qa|grep -i mysql
2. Stop the mysql service and delete the package
service mysql stop
rpm -ev MySQL-client-5.5.25a-1.rhel5
rpm -ev MySQL-server-5.5.25a-1.rhel5
If you are prompted with a dependency package error, use the following command to try
rpm -ev MySQL-client-5.5.25a-1.rhel5 --nodeps
If you get an error: error: %preun(xxxxxx) scriptlet failed, exit status 1
then try the following command:
rpm -e --noscripts MySQL-client-5.5.25a-1.rhel5
3. Find the directory of the previous old version of mysql, and delete the files and libraries of the old version of mysql
whereis 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
Note: /etc/my.cnf will not be deleted after uninstallation, it needs to be deleted manually
rm -rf /etc/my.cnf
4. Find again if the machine is installed with mysql
rpm -qa|grep -i mysql
No result, indicating that it has been uninstalled completely