Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7

Remove MariaDB or MySQL from CentOS 7, Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7,I installed MariaDB on CentOS 7 but I had some problems with some configuration, now it is completely misconfigured.

Thus, I wanted to remove the MariaDB with “yum remove mariadb mariadb-server”, after that I reinstalled it with “yum install mariadb mariadb-server”.

Unfortunately, the configuration remains. It seems as if yum remove don’t delete all MariaDB Config-Files.

How can I remove MariaDB completely from CentOS 7?

Answer:

These steps are working on CentOS 6.5 so they should work on CentOS 7 too:

(EDIT – exactly the same steps work for MariaDB 10.3 on CentOS 8)

  1. yum remove mariadb mariadb-server
  2. rm -rf /var/lib/mysql If your datadir in /etc/my.cnf points to a different directory, remove that directory instead of /var/lib/mysql
  3. rm /etc/my.cnf the file might have already been deleted at step 1
  4. Optional step: rm ~/.my.cnf
  5. yum install mariadb mariadb-server

[EDIT] – Update for MariaDB 10.1 on CentOS 7

The steps above worked for CentOS 6.5 and MariaDB 10.

I’ve just installed MariaDB 10.1 on CentOS 7 and some of the steps are slightly different.

Step 1 would become:

yum remove MariaDB-server MariaDB-client

Step 5 would become:

yum install MariaDB-server MariaDB-client

The other steps remain the same.

Source: https://stackoverflow.com/

See More: SQL Check if table exists

One thought on “Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7

Leave a Reply

Your email address will not be published. Required fields are marked *