How to install MariaDB server on CentOS/RHEL 8

In this tutorial, you will see How to install MariaDB Server on RHEL/CentOS 8.

At this moment, the latest stable version of MariaDB is 10.4. If you want to install any other Alpha or any other version of MariaDB. So, you can visit on the MariaDB website MariaDB Repository. And you can generate a repository file for a specific MariaDB version.

MariaDB is an open-source relational database management system (RDBMS). This is a compatible replacement for the widely used MySQL database technology.

For the installation of MariaDB 10.4 on CentOS 8 and RHEL 8, follow the below steps.

Creating the MariaDB repository 

Step 1: Firstly, we have to enable the MariaDB repository. To create a repository file, the location will be /etc/yum.repos.d and there we have to create the file with the name MariaDB.repo. So let’s create a repo file.

Use the cd command to go to the yum.repos.d directory.

cd /etc/yum.repos.d

Create a repo list or CentOS 8

We are creating this repo file for CentOS 8. Now create a file using any of your choice based editors. Here, I am using vim editors.

vim MariaDB.repo 

Hit Enter key and press i to go into insert mode and copy the below-highlighted contents and paste it. After pasting the content save it by pressing Esc key and typing :wq.

# MariaDB 10.4 CentOS repository list - created 2020-06-03 10:21 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Create repo list on Red Hat Enterprise Linux 8

If you want to create this repo file for RHEL8, then you have to create a file using any of the editors as per your choice. Here, I am using vim editor.

vim MariaDB.repo 

Hit Enter key and press i to go into insert mode and copy the below-highlighted contents and paste it. After pasting the content save it by pressing Esc key and by typing :wq.

# MariaDB 10.4 RedHat repository list - created 2020-06-03 10:21 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Installing MariaDB

Step 2: To install MariaDB use the below command, it will install the latest version 10.4 of MariaDB. I am using dnf command for installation but you can also use yum command.

dnf -y install MariaDB-server MariaDB-client 

Managing the MariaDB service

Step 3: In this step, we’ll start the service, and also we’ll put in auto start on system boot with enable.

systemctl start mariadb
systemctl enable mariadb

Now, check the service status, if it running or not. so you can use the below command for that.

systemctl status mariadb
install mariadb server
Checking the status of MariaDB service

Configuring and securing MariaDB Server

Step 4: MariaDB Server 10.4 writes all data files and tablespaces to a directory on the file system called the data directory.  Run the mysql_install_db utility to provision this directory.

mysql_secure_installation

After entering the above command, it will prompt to set up the root password, remove anonymous user accounts, restrict root user access to the local machine, remove the test database. So, you can answer Yes to all the questions.

Conclusion

In this tutorial, you learned about how to install MariaDB Server on RHEL 8 / CentOS 8. So, I hope, you find it useful, but if you have any questions, you can ask in the comment section.

For futher, you can read,

Leave a Reply