How to remove MariaDB completely from CentOS 7 or RHEL 7?

In my centos server, the MariaDB server crashed, and I want to reinstall it. I want to remove MariaDB and its configuration. Then I want to install it again. Can anyone show me how I can do it?

You can follow the steps to uninstall and reinstall MariaDB.
1. Remove MariaDB

yum remove mariadb mariadb-server

2. Remove the MySQL data directory.

rm -rf /var/lib/mysql

If your datadir is configured to a different directory, then remove that directory instead of /var/lib/mysql
3. Remove the MySQL configuration file

rm /etc/my.cnf

This file might have already been deleted at step 1
4. Optional step

rm ~/.my.cnf

5. Finally, install MariaDB again.

yum install mariadb mariadb-server

These steps should be working on CentOS 6.5, CentOS 7 and CentOS 8