How to Install MariaDB on CentOS 8

MariaDB is an open-source, community-developed relational database management system. It is forked from MySQL and created and maintained by the developers who created MySQL. MariaDB is intended to be highly compatible with MySQL but new features have been added to MariaDB like new storage engines (Aria, ColumnStore, MyRocks).

In this article, we will take a look at the installation and configuration of MariaDB on CentOS 8 Linux.

Step 1: Enable the MariaDB Repository on CentOS 8

Go to the official MariaDB downloads page and select CentOS as the distribution and CentOS 8 as the version and MariaDB 10.5 (stable version) to get the repository.

Once you select the details, you will get MariaDB YUM repository entires. Copy and paste these entries into a file called /etc/yum.repos.d/MariaDB.repo.

$ sudo vim /etc/yum.repos.d/mariadb.repo
# MariaDB 10.5 CentOS repository list - created 2020-12-15 07:13 UTC
name = MariaDB
baseurl =

Once the repository file in place, you can verify the repository by running the following command.

$ dnf repolist
Check MariaDB Repository
Check MariaDB Repository

Step 2: Installing MariaDB on CentOS 8

Now use the dnf command to install the MariaDB package.

$ sudo dnf install MariaDB-server -y

Next, start the MariaDB service and enable it to autostart during system startup.

$ systemctl start mariadb
$ systemctl enable mariadb

Check the status of the MariaDB service by running the following command.

$ systemctl status mariadb 
Check MariaDB Status
Check MariaDB Status

If you have a firewall enabled, you need to add MariaDB to the firewall rule by running the below command. Once the rule is added, the firewall needs to be reloaded.

$ sudo firewall-cmd --permanent --add-service=mysql
$ sudo firewall-cmd --reload

Step 3: Securing the MariaDB Server on CentOS 8

As the last step, we need to run a secure MariaDB installation script. This script takes care of setting up the root password, reloading privileges, removing test databases, disallowing root login.

$ sudo mysql_secure_installation
Secure MariaDB in CentOS 8
Secure MariaDB in CentOS 8

Now connect to MariaDB as the root user and check the version by running the following commands.

$ mysql -uroot -p
Connect to MariaDB Shell
Connect to MariaDB Shell

That’s it for this article. We have seen how to install and configure MariaDB on CentOS 8 Linux.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Karthick Sudhakar
I am a Big data Engineer from India, Chennai working on a top MNC with a vision of being a bridge between technology and mankind.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 thoughts on “How to Install MariaDB on CentOS 8”

Leave a Reply to karthick Sudhakar Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.