[mysql] 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?

This question is related to mysql centos mariadb yum rhel

The answer is


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.


systemd

sudo systemctl stop mysqld.service && sudo yum remove -y mariadb mariadb-server && sudo rm -rf /var/lib/mysql /etc/my.cnf

sysvinit

sudo service mysql stop && sudo apt-get remove mariadb mariadb-server && sudo rm -rf /var/lib/mysql /etc/my.cnf

To update and answer the question without breaking mail servers. Later versions of CentOS 7 have MariaDB included as the base along with PostFix which relies on MariaDB. Removing using yum will also remove postfix and perl-DBD-MySQL. To get around this and keep postfix in place, first make a copy of /usr/lib64/libmysqlclient.so.18 (which is what postfix depends on) and then use:

rpm -qa | grep mariadb

then remove the mariadb packages using (changing to your versions):

rpm -e --nodeps "mariadb-libs-5.5.56-2.el7.x86_64"
rpm -e --nodeps "mariadb-server-5.5.56-2.el7.x86_64"
rpm -e --nodeps "mariadb-5.5.56-2.el7.x86_64"

Delete left over files and folders (which also removes any databases):

rm -f /var/log/mariadb
rm -f /var/log/mariadb/mariadb.log.rpmsave
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/share/mysql

Put back the copy of /usr/lib64/libmysqlclient.so.18 you made at the start and you can restart postfix.

There is more detail at https://code.trev.id.au/centos-7-remove-mariadb-replace-mysql/ which describes how to replace mariaDB with MySQL


Examples related to mysql

Implement specialization in ER diagram How to post query parameters with Axios? PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver' phpMyAdmin - Error > Incorrect format parameter? Authentication plugin 'caching_sha2_password' is not supported How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Connection Java-MySql : Public Key Retrieval is not allowed How to grant all privileges to root user in MySQL 8.0 MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

Examples related to centos

How to uninstall an older PHP version from centOS7 Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details pip install - locale.Error: unsupported locale setting ssh : Permission denied (publickey,gssapi-with-mic) How to change the MySQL root account password on CentOS7? Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7 ffprobe or avprobe not found. Please install one How to check all versions of python installed on osx and centos Cannot find java. Please use the --jdkhome switch VirtualBox: mount.vboxsf: mounting failed with the error: No such device

Examples related to mariadb

How to turn on/off MySQL strict mode in localhost (xampp)? Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7 Access denied for user 'root'@'localhost' (using password: YES) after new installation on Ubuntu Database corruption with MariaDB : Table doesn't exist in engine phpMyAdmin allow remote users ERROR 1452: Cannot add or update a child row: a foreign key constraint fails What's the default password of mariadb on fedora? Cast int to varchar MySQL: Grant **all** privileges on database MySQL - SELECT * INTO OUTFILE LOCAL ?

Examples related to yum

How to Install gcc 5.3 with yum on CentOS 7.2? Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7 RHEL 6 - how to install 'GLIBC_2.14' or 'GLIBC_2.15'? CentOS 7 and Puppet unable to install nc How to yum install Node.JS on Amazon Linux yum error "Cannot retrieve metalink for repository: epel. Please verify its path and try again" updating ContextBroker How to install latest version of git on CentOS 7.x/6.x Upgrading PHP on CentOS 6.5 (Final) Yum fails with - There are no enabled repos. Why does configure say no C compiler found when GCC is installed?

Examples related to rhel

Docker CE on RHEL - Requires: container-selinux >= 2.9 How to redirect output of systemd service to a file Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7 RHEL 6 - how to install 'GLIBC_2.14' or 'GLIBC_2.15'? How to run a command as a specific user in an init script? Error when using scp command "bash: scp: command not found" How do you scroll up/down on the console of a Linux VM How to find which version of Oracle is installed on a Linux server (In terminal) Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist Installing Python 3 on RHEL