MariaDB is a community-developed, fully open-source relational database and the default MySQL-compatible database in RHEL 9. It was created by the original MySQL developers after Oracle’s acquisition of MySQL and maintains complete protocol and API compatibility with MySQL applications. MariaDB 10.11 LTS is the current Long Term Support release, offering features that MySQL 8 does not include: temporal data tables (bi-temporal tables), more storage engines (Aria, ColumnStore, MyRocks), superior performance on certain read-heavy workloads, and a truly open development process. RHEL 9 ships MariaDB 10.5 in its AppStream; for MariaDB 10.11 LTS you need the MariaDB Foundation repository. This guide covers both installation methods, securing the installation, creating databases, and configuring performance settings.

Prerequisites

  • RHEL 9 with sudo/root access

Step 1 — Install MariaDB from RHEL 9 AppStream (10.5)

# Quick install — MariaDB 10.5 from AppStream
dnf install -y mariadb-server
systemctl enable --now mariadb
mysql --version

Step 2 — Install MariaDB 10.11 LTS (Recommended)

# Add the MariaDB Foundation repo
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version="mariadb-10.11"
dnf install -y MariaDB-server MariaDB-client
systemctl enable --now mariadb
mysql --version

Step 3 — Secure the Installation

mysql_secure_installation
# Set root password, remove anonymous users, disallow remote root, remove test DB

Step 4 — Create a Database and User

mysql -u root -p
-- Inside MariaDB shell
SELECT VERSION();

CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON myapp.* TO 'myapp_user'@'localhost';
FLUSH PRIVILEGES;
SHOW DATABASES;
EXIT;

Step 5 — Configure MariaDB for Performance

# /etc/my.cnf.d/mariadb-custom.cnf
[mysqld]
# InnoDB buffer pool — 70% of available RAM
innodb_buffer_pool_size    = 1G
innodb_log_file_size       = 256M
innodb_flush_log_at_trx_commit = 1

# Connection settings
max_connections            = 200
thread_cache_size          = 16

# Query cache (MariaDB keeps query cache; MySQL 8 removed it)
query_cache_type           = 1
query_cache_limit          = 2M
query_cache_size           = 64M

# Slow query log
slow_query_log             = 1
slow_query_log_file        = /var/log/mariadb/slow.log
long_query_time            = 2

# Character set
character-set-server       = utf8mb4
collation-server           = utf8mb4_unicode_ci
mkdir -p /var/log/mariadb && chown mysql:mysql /var/log/mariadb
systemctl restart mariadb

Step 6 — Automated Backup

# /etc/cron.d/mariadb-backup
0 2 * * * root mysqldump -u root -pStrongPassword --all-databases | gzip > /var/backups/mariadb-all-$(date +%Y%m%d).sql.gz
0 3 * * * root find /var/backups/ -name "mariadb-*.sql.gz" -mtime +7 -delete

Conclusion

MariaDB on RHEL 9 provides a fully MySQL-compatible, open-source relational database with additional features and performance improvements. The RHEL 9 AppStream provides MariaDB 10.5 for quick installation; the MariaDB Foundation repository provides the current 10.11 LTS for production deployments. Configuring InnoDB buffer pool sizing, the query cache, and slow query logging establishes a solid foundation for any PHP or Python web application.

Next steps: How to Install MySQL 8 on RHEL 9, How to Configure MariaDB Galera Cluster on RHEL 9, and How to Install PostgreSQL on RHEL 9.