How To Completely Removing MySQL Server in CentOS

Completely Removing MySQL Server in CentOS

In this tutorial, we will show you how to completely remove MySQL on your CentOS server. For those of you who didn’t know, MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. The MySQL source code is freely available because it was originally developed as freeware. MySQL is written in C and C++ and is compatible with all major operating systems. MySQL can be used for a variety of applications but is most commonly found on Web servers.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you step-by-step removing MySQL on the CentOS server. Maybe it’s a good idea to back up databases before doing this.


  • A server running one of the following operating systems: CentOS Linux.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Completely Removing MySQL Server in CentOS

Step 1: Checklist the MySQL rpm which is installed on the server

#rpm -qa | grep mysql
#yum list installed | grep mysql

Completely Removing MySQL Server in CentOS

Step 2: Removing MySQL Server in CentOS.

Now we remove all MySQL-related packages using the following commands below:

#yum remove mysql-client mysql-server mysql-common mysql-devel

 Completely Removing MySQL Server in CentOS

Step 3: Delete the databases folder.

Now we delete the MySQL data directory using the following command:

#rm -rf /var/lib/mysql/
#rm -rf /etc/my.cnf

Next, Remove the MySQL user and group:

#sudo userdel mysql
#sudo groupdel mysql

Finally, delete the MySQL configuration files:

#sudo rm -f /etc/my.cnf

 If you don’t know how to reinstall the MySQL database server, check out our tutorial here.

Congratulations! You have successfully removed MySQL. Thanks for using this tutorial for removing MySQL from the CentOS system. For additional help or useful information, we recommend you check the official MySQL website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
Back to top button