November 12, 2025
Tutorials

How to Install MariaDB on CentOS 10

How to Install MariaDB on CentOS 10

MariaDB is a great open-source solution for setting up a CentOS database server. MariaDB was originally developed as a fork of MySQL by a community. It offers a high level of performance, advanced features, and compatibility with MySQL syntax, making it popular among system administrators and developers.

This guide will show you all the possible ways to install MariaDB in CentOS 10, from the default repository to source compilation. It will explain the reasons behind each installation method and help you ensure that your MariaDB system is stable, secure, and optimized for performance.

Table of Contents

How to Install MariaDB on CentOS 10

It is easy to install MariaDB under CentOS, but it depends on what you want. The default CentOS repository will provide a stable and quick setup. If you need the most recent features, then the official MariaDB repository is the best option. If you are a developer and want to have full control of configuration and performance, then compiling MariaDB is the best option.

Here are all the possible ways to install MariaDB in CentOS 10, from the easiest repository-based installations to advanced source compiling. Each method is explained in simple, step-by-step terms and includes clear, concise explanations.

Method 1: Install MariaDB from the Default CentOS Repository

This is the easiest and most reliable way for most users. CentOS includes MariaDB as part of its default repository. You can therefore install it without needing to add any external sources. It is stable and suitable for most users.

Step 1: Install MariaDB Server

Download and install MariaDB using the CentOS package manager.

sudo yum install mariadb-server

sudo yum install mariadb-server

Step 2: Start and Enable MariaDB

Start the database service, and ensure that it starts automatically at system startup.

sudo systemctl start mariadb

sudo systemctl enable mariadb

Start and enable mariadb service

Step 3: Secure Installation

Run the security script in order to disable defaults that are not secure, remove anonymous users, and set a root password.

sudo mysql_secure_installation

sudo mysql_secure_installation

Step 4: Verify Installation

MariaDB must be installed and accessible.

mysql -V

mysql -V

Best for: Stable, out-of-the-box setup for most CentOS users.

Method 2: Install MariaDB Using DNF

CentOS 8 uses DNF instead of YUM. DNF offers modular repositories, which allow you to choose specific MariaDB releases easily. This is an easy and modern way to install MariaDB.

Step 1: Enable the AppStream Module

Select your preferred MariaDB version and list it.

sudo dnf module enable mariadb:10.3

Step 2: Install MariaDB

Install MariaDB using the DNF package.

sudo dnf install mariadb-server -y

sudo dnf install mariadb-server -y

Step 3: Start and Enable the Service

Start MariaDB, and configure it so that it starts automatically every time your server reboots.

sudo systemctl start mariadb

sudo systemctl enable mariadb

Start and enable mariadb service

Step 4: Secure MariaDB

Use the post-installation script for a more secure setup.

sudo mysql_secure_installation

sudo mysql_secure_installation

Best for: CentOS 8/Stream users who want version control and DNF module support.

Method 3: Compile MariaDB from Source

This method allows you to have full control of the installation. You can build MariaDB directly from its source code. This is the best option for users or developers who require custom compile flags, optimization flags, or experimental builds.

Step 1: Install Build Dependencies

Install all the compiler tools and libraries required to compile MariaDB.

sudo yum groupinstall “Development Tools” -y

sudo yum install cmake gcc gcc-c++ bison ncurses-devel openssl-devel -y

sudo yum groupinstall "Development Tools" -y

Step 2: Download Source Code

Download the latest MariaDB Source Package from the official site.

wget https://downloads.mariadb.org/interstitial/mariadb-10.11.6/source/mariadb-10.11.6.tar.gz

tar -xvf mariadb-10.11.6.tar.gz

cd mariadb-10.11.6

wget https://downloads.mariadb.org/interstitial/mariadb-10.11.6/source/mariadb-10.11.6.tar.gz

Step 3: Configure Build

Configure MariaDB’s installation and build paths using CMake.

cd mariadb-10.11.6
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

Step 4: Compile and Install

Install the source code on your system after you have built it.

make

sudo make install

make

Make sure to check out our website for more information.

Step 5: Create a System User

Create a mysql dedicated user and grant permissions for the data directory.

sudo useradd mysql

sudo mkdir /usr/local/mysql/data

sudo chown -R mysql:mysql /usr/local/mysql

sudo mkdir /usr/local/mysql/data

Step 6: Initialize and Start MariaDB

Start MariaDB manually and initialize the database.

cd /usr/local/mysql

sudo scripts/mysql_install_db –user=mysql

sudo bin/mysqld_safe –user=mysql &

sudo bin/mysqld_safe --user=mysql &

That is all from the guide.

Conclusion

To install MariaDB on CentOS, you can use several methods: the easiest is installing from the default CentOS repository using sudo yum install mariadb-server -y, then starting and securing it with sudo systemctl start mariadb, sudo systemctl enable mariadb, and sudo mysql_secure_installation; alternatively, you can add the official MariaDB repository to install the latest version, use the DNF module method on CentOS 8 or Stream to enable specific versions, or compile MariaDB from source for custom configurations, each method offering flexibility depending on whether you prioritize stability, version control, or performance customization.

    Leave feedback about this

    • Quality
    • Price
    • Service

    PROS

    +
    Add Field

    CONS

    +
    Add Field
    Choose Image
    Choose Video