Home Linux CentOS Remove MySQL Completely from CentOS 7 Server

Remove MySQL Completely from CentOS 7 Server

How can I remove MySQL completely from my CentOS 7 Linux server??

Remove MySQL Completely from CentOS
Remove MySQL Completely from CentOS

As a system administrator, sometimes you get a situation where you face the issue with the MySQL installation and you decide to install it again. But removing only the MySQL server package doesn’t fix the issue because old settings again affect the new installation. For this need to completely remove the MySQL packages and remove all the old settings.

Remember: Make sure you have the backup of the databases before removing MySQL and all its settings. To avoid any data loss.

– Remove MySQL from the Server.

– To remove the MySQL data directory.

– Now again install MySQL with the fresh settings.

Step 1. Remove MySQL

The first step is to remove the MySQL package from the CentOS 7 server. For this just run the following command.

# yum remove mysql mysql-server

Step 2. Remove MySQL Data Directory

By default MySQL data directory path is /var/lib/mysql. Instead of removing MySQL data directory we will suggest you just rename this directory to keep a backup of the old settings. You can rename this directory like old_backup_mysql.

# mv /var/lib/mysql /var/lib/old_backup_mysql 

READ: How to Take Backup and Restore the MySQL Database.

Step 3. Now Install MySQL Again

In the above steps, MySQL server packages removed. MySQL data directory also deleted/renamed. Now finally again we will install the MySQL packages.

# yum install mysql mysql-server

This will create new mysql data directory under the default path i.e. /var/lib.

Read: Install MySQL 8 Version on CentOS 7

That’s it. You completely removed MySQL from CentOS 7 and again installed MySQL with new settings.


Please enter your comment!
Please enter your name here