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
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

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 this article helped, with someone on your team.

TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
☕ Buy Me a Coffee
Karthick
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.

2 Comments

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.

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Something went wrong. Please try again.
Check your email for a magic link to get started.