How to Remove MySQL Completely from Linux System

Some time we faces issues with MySQL installation on Linux machine. If we simply remove MySQL packages and re-install doesn’t fixes the issue, in that case old settings may still exists on server which again affects new install. In that case first uninstall MySQL completely from system and erase all settings of old install. To do the same follow the below settings.

Note: Please do not use below steps if MySQL have any running databases.

Step 1: Uninstall MySQL Packages

First uninstall all the MySQL packages installed on your server

 # yum remove mysql mysql-server
Step 2: Romove MySQL Directory

Now we need to remove MySQL data directory from system which by default exists at /var/lib/mysql. If you didn’t find this, It may be changed to some other place, which you can find in my.cnf file with variable datadir. Delete the /var/lib/mysql directory from system but we prefer to rename it to keep a backup of existing files.

 # mv /var/lib/mysql /var/lib/mysql_old_backup
Step 3: Install MySQL Packages Again

After removing MySQL completely, install it again using yum package manager, It will re create mysql directory under /var/lib/.

# yum install mysql mysql-server

After completing above three steps, now you have a fresh MySQL install on your system with new settings.

Source : https://cakrawalananto.wordpress.com/2011/11/25/install-apache-mysql-php-di-centos/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s