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.

A passionate software engineer who loves to explore new technologies. He is a public speaker and loves writing about technology, especially about Linux and open source.

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.


Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.