How To Install MariaDB on AlmaLinux 8



MariaDB is an open-source database management system, commonly used as an alternative for the MySQL portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It is intended to be a drop-in replacement for MySQL.

In this tutorial, we will explain how to install the latest version of MariaDB on a AlmaLinux 8 server.


To follow this tutorial, you will need a AlmaLinux 8 server with a non-root sudo-enabled user.

Step 1 — Installing MariaDB

First, use dnf to install the MariaDB package:

sudo dnf install mariadb-server

You will be asked to confirm the action. Press y then ENTER to proceed.

Once the installation is complete, start the service with systemctl:

sudo systemctl start mariadb

Then check the status of the service:

sudo systemctl status mariadb
mariadb.service - MariaDB 10.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor pr>
   Active: active (running) since Thu 2021-12-30 02:36:07 EST; 12s ago
     Docs: man:mysqld(8)
  Process: 6335 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, st>
  Process: 6193 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service >
  Process: 6158 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, stat>
 Main PID: 6300 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 24577)
   Memory: 84.1M
   CGroup: /system.slice/mariadb.service
           └─6300 /usr/libexec/mysqld --basedir=/usr

If MariaDB has successfully started, the output should show active (running) and the final line should look something like:

Dec 30 02:36:07 systemd[1]: Started MariaDB 10.3 database server.

Next, let’s take a moment to ensure that MariaDB starts at boot, using the systemctl enable command:

sudo systemctl enable mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/mariadb.service.

We now have MariaDB running and configured to run at startup. Next, we’ll turn our attention to securing our installation.

Step 2 — Securing the MariaDB Server

MariaDB includes a security script to change some of the less secure default options for things like remote root logins and sample users. Use this command to run the security script:

sudo mysql_secure_installation

The script provides a detailed explanation for every step. The first step asks for the root password, which hasn’t been set so we’ll press ENTER as it recommends. Next, we’ll be prompted to set that root password. Keep in mind that this is for the root database user, not the root user for your AlmaLinux server itself.

Type Y then ENTER to enter a password for the root database user, then follow the prompts.

After updating the password, we will accept all the security suggestions that follow by pressing y and then ENTER. This will remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables.

Now that we’ve secured the installation, we’ll verify it’s working by connecting to the database.

Step 3 — Testing the Installation

We can verify our installation and get information about it by connecting with the mysqladmin tool, a client that lets you run administrative commands. Use the following command to connect to MariaDB as root (-u root), prompt for a password (-p), and return the version.

mysqladmin -u root -p version


You should see output similar to this:

mysqladmin  Ver 9.1 Distrib 10.3.28-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Server version          10.3.28-MariaDB
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 9 min 20 sec

Threads: 6  Questions: 16  Slow queries: 0  Opens: 18  Flush tables: 1  Open tables: 11  Queries per second avg: 0.028

This indicates the installation has been successful.


In this guide you installed MariaDB to act as an SQL server. During the installation process you also secured the server. Optionally, you also created a separate password-authenticated administrative user.

Now that you have a running and secure MariaDB server, here some examples of next steps that you can take to work with the server:

Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.