How to Install MariaDB on CentOS 8 Linux Operating System

Update on:
Sep 2, 2021

MariaDB is the latest open source and popular relational database management system, compatible and replacement of MySQL.

MariaDB developed with MySQL original developers and many people from the community.

The CentOS 8 Operating System release was replaced MySQL with MariaDB as the default database system.

In this tutorial article, we will show how to install MariaDB into CentOS, but for any reason you want to install MySQL into your CentOS, you can check the How to install MySQL on CentOS 8 tutorial.

If your required application does not have any specific database requirements, you should go with MariaDB, default database of CentOS 8 Operating System.


Before starting the process of installing MariaDB, make sure you have a CentOS 8 running system and a user to login into the system with sudo privileges.

Install MariaDB on CentOS 8

The default CentOS 8 repository providing MariaDB version 5.5, it is not the latest version of MariaDB, but it is a stable release.

To install MariaDB into CentOS 8, you need to follow the below process:

Step 1 – Install MariaDB

To install MariaDB 5.5 version into CentOS 8 by using the following Command

$ sudo yum install mariadb-server

Step 2 – Start MariaDB Service

After installation of MariaDB, the service automatically started, but you can use below command for manually start the MariaDB service:

$ sudo systemctl start mariadb

Step 3 – Enable MariaDB Service

You should enable the MariaDB service to make MariaDB service auto start on system startup, by using the following command:

$ sudo systemctl enable mariadb

Step 4 – Verify MariaDB

To verify the MariaDB service, you can check the status of the service by using the following command:

$ sudo systemctl status mariadb

Step 5 – MariaDB Secure Installation

To secure the MariaDB installation like change root password, restrict root access to localhost, remove test database, etc. to perform this task, you should run this command:

$ sudo mysql_secure_installation

Install Latest MariaDB on CentOS 8

The latest MariaDB server version 10.3 is not coming with default repository of CentOS 8. If you want to install the latest version of MariaDB into CentOS 8 system, create MariaDB repository file to install the latest MariaDB directly from official repository of MariaDB packages.

Let’s start the installation process of MariaDB 10.3 into CentOS 8 by the following procedure:

Step 1 – Enable MariaDB Repository

To enable MariaDB repository into a CentOS system, you need to create a repository file into /etc/yum.repos.d/ directory, as you can see below, we have created MariaDB repository file with the name of MariaDB.repo, you should also create the same file into your system.

Step 2 – Install MariaDB Server and Client

After creating the repository file, you should update your system’s repository package list by using the following command:

$ sudo yum update

Once the CentOS package is updated, you can use the following command to install mariaDB Server and Client:

$sudo yum install MariaDB-server MariaDB-client

You may get below the screen to import MariaDB GPG key into the system:

You should type Y (yes) to allow to download the key file.

Step 3 – Enable and start the MariaDB Service

Once the installation of MariaDB completed, you should enable and start the service, as shown below:

$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb

Step 4 – Verify MariaDB installation

You can verify the MariaDB installation by checking the status of service using the following command:

$ sudo systemctl status mariadb

Step 5 – MariaDB Secure Installation

After installation and running service need to make your MariaDB secure, and to perform the security operation need to execute mysql_secure_instalaltion script, as shown below:

$ sudo mysql_secure_installation

This script will use to set the password for root, restrict root user to localhost, remove anonymous users, and remove test database, etc.

All step will appear on the screen with detailed, and you need to press Y as your answer to accept the security changes.

MariaDB connection from CLI

To connect MariaDB server using terminal or CLI with root user credential type the below command:

$ mysql –u root –p

Now it will ask you to enter a password for the root user and press enter.

Once you logged in into MariaDB shell and you will get a screen like below:


In this acritical, we learned how to install MariaDB into CentOS 8 system. We also learned to install MariaDB directly from MariaDB repository.

Now MariaDB is installed in your system successful, and you know how to connect with MariaDB shell to perform Database commands and operations.

Related Posts

How to Install MongoDB on CentOS 8 Linux

How to Install MongoDB on CentOS 8 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

How to Install OpenCV on CentOS 8 Linux

How to Install OpenCV on CentOS 8 Linux

OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in commercial...

How to install and use FFmpeg on CentOS 8 Linux Operating System

How to install and use FFmpeg on CentOS 8 Linux Operating System

The FFmpeg is the most potent and useful command-line tool on Linux system for multimedia files transcoding. You can use FFmpeg to convert multimedia files between various video and audio formats and resize videos. It has multiple audio and video libraries such as...

How to Install VirtualBox on CentOS 8 Linux

How to Install VirtualBox on CentOS 8 Linux

VirtualBox is an Open Source tool, known as a cross-platform virtualization application or software. It used to run multiple operating systems or virtual machines simultaneously on a single hardware. In this VirtualBox installation tutorial, we will explain the...

Follow Us

Our Communities

More on CentOS

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!



Submit a Comment

Your email address will not be published.

three + 13 =