Detailed explanation of completely uninstalling mysql under Linux

1. Use the following command to check the current installation of mysql and find out whether mysql was installed before

 

rpm -qa|grep -i mysql

It can be seen as shown in the following figure:

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 包名

1 2

rpm -ev MySQL-client-5.5.25a-1.rhel5 rpm -ev MySQL-server-5.5.25a-1.rhel5

If it prompts a dependency package error, use the following command to try

 

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:

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

1

find / -name mysql

The search results are as follows:

1 2 3 4 5

find / -name mysql   /var/lib/mysql /var/lib/mysql/mysql /usr/lib64/mysql

Delete the corresponding mysql directory

1 2 3

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

1

rm -rf /etc/my.cnf

4. Find out if mysql is installed on the machine again

1

rpm -qa|grep -i mysql

Summarize

There is no result, indicating that it has been uninstalled completely, and then you can directly install mysql

 

 

{{o.name}}
{{m.name}}

Guess you like

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