How to uninstall MySQL Completely from Linux System

Some time we encounter problems with MySQL set up on Linux server. If we simply delete MySQL package and re-install it doesn’t resolve the problem, in that situation old configurations may still remains on server which again affects new set up. So first we have to uninstall MySQL completely from system and remove all configurations of old set up. 

[wpfmb type=’info’ theme=2]Note: Before proceeding make sure that MySQL do not have any running databases.[/wpfmb]

First uninstall all the MySQL packages installed on your server :

yum remove mysql mysql-server

Now we need to remove MySQL data directory from server which by default  at /var/lib/mysql. If you didn’t find, It might be changed to some other directory, which you can check in my.cnf file with variable datadir. remove the /var/lib/mysql directory from system but preferred to rename it to keep a back-up of current files.

mv /var/lib/mysql /var/lib/mysql_old_backup

After removing MySQL completely, We can reinstall it again using yum package manager:

yum install mysql mysql-server

After completing all this , Now we have a fresh MySQL install on our server with new settings.