1. Use the following command to view the current installation of mysql
- 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- rpm -ev MySQL-client-5.5.25a-1.rhel5
- rpm -ev MySQL-server-5.5.25a-1.rhel5
- 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:
- 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 mysqlThe search results are as follows:
- 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
- rm -rf /etc/my.cnf
4. Find out if mysql is installed on the machine again
- rpm -qa|grep -i mysql