How to Install MariaDB on AlmaLinux 10

Published: 2026-06-27
Google AdSense 广告位 (待申请通过后开启)

Introduction

MariaDB is a popular open-source relational database management system that is fully compatible with MySQL in many scenarios. It is widely used for web applications, content management systems, and enterprise services.

This guide explains how to install MariaDB on AlmaLinux 10, start the service, secure the installation, create a database, and verify that everything is working correctly.

Prerequisites

Before installing MariaDB, ensure that:

* You are running AlmaLinux 10.

* You have sudo or root privileges.

* Your system packages are up to date.

Update System Packages

Update package metadata:

sudo dnf update -y

Install MariaDB

Install the MariaDB server and client packages:

sudo dnf install mariadb-server mariadb -y
Image-1
Image-1

Verify the installation:

rpm -qa | grep mariadb

Start and Enable MariaDB

Enable MariaDB to start automatically at boot:

sudo systemctl enable mariadb

Start the MariaDB service:

sudo systemctl start mariadb

Check the service status:

sudo systemctl status mariadb
Image-2
Image-2

The service should display **active (running)**.

Verify the Installation

Display the installed version:

mariadb --version

Or:

mysql --version

Secure the Installation

Run the security configuration wizard:

sudo mysql_secure_installation

During the setup, you can:

* Set the root password.

* Remove anonymous users.

* Disallow remote root login.

* Remove the test database.

* Reload the privilege tables.

Log in to MariaDB

Log in as the root user:

sudo mariadb

Or:

mysql -u root -p

Create a Test Database

Create a database:

CREATE DATABASE testdb;

Display all databases:

SHOW DATABASES;

Create a Test User

Create a user:

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'StrongPassword';

Grant privileges:

GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost';

Reload privileges:

FLUSH PRIVILEGES;

Common MariaDB Commands

Show databases:

SHOW DATABASES;

Select a database:

USE testdb;

Show tables:

SHOW TABLES;

Exit MariaDB:

EXIT;

MariaDB Data Directory

The default database directory is typically:

/var/lib/mysql

Check the directory size:

sudo du -sh /var/lib/mysql

Stop and Restart MariaDB

Stop the service:

sudo systemctl stop mariadb

Restart the service:

sudo systemctl restart mariadb

Uninstall MariaDB

Remove MariaDB packages:

sudo dnf remove mariadb-server mariadb -y

Optionally remove the database files:

sudo rm -rf /var/lib/mysql

> **Warning:** This permanently deletes all databases.

Conclusion

Installing MariaDB on AlmaLinux 10 is straightforward using the DNF package manager. After installation, secure the server, create databases and users, and verify the installation before deploying your applications.

Explore More

Technology Guides →

Southeast Asia Insights →