MariaDB can be installed on RHEL 9 in just a few steps:

  1. Update RHEL 9 to the latest version
  2. Set up the MariaDB repository and configure the database server
  3. Install and start MariaDB
  4. Secure the database and configure the firewall
  5. Create a user account and enable remote access

What are the advantages of MariaDB on RHEL 9?

MariaDB delivers high performance and reliability. RHEL 9 provides a stable, secure operating system with long-term support. Combined, the two create a robust database environment that is both maintainable and easy to manage over time.

What are the requirements for installing MariaDB on RHEL 9?

Before starting the installation, make sure your system meets these requirements:

  • RHEL 9 installed
  • Root privileges or access via sudo
  • At least 1 GB RAM (2 GB is recommended)
  • At least 2 GB of free disk space
Managed Database Services
Time-saving database services
  • Enterprise-grade architecture managed by experts
  • Flexible solutions tailored to your requirements
  • Leading security in ISO-certified data centers

How to install MariaDB on RHEL 9

If you need a relational database on RHEL 9, MariaDB can be set up quickly and reliably. On a standard RHEL 9 system, the installation process itself is pretty straightforward.

Step 1: Update the system

Before installing any packages, update your system to the latest version. This prevents conflicts with outdated dependencies.

sudo dnf update -y
sudo dnf upgrade -y
bash

Step 2: Add the MariaDB repository

RHEL 9 typically provides an older version of MariaDB. To install the latest release, add the official repository. Create a new configuration file:

sudo vi /etc/yum.repos.d/MariaDB.repo
bash

Then insert the following content:

[mariadb]
name = MariaDB
baseurl = https://downloads.mariadb.com/MariaDB/mariadb-11.7/yum/rhel9-amd64
gpgkey=https://downloads.mariadb.com/MariaDB/MariaDB-Server-GPG-KEY
gpgcheck=1
bash

Clear the package cache and rebuild it:

sudo dnf clean all
sudo dnf makecache
bash

Step 3: Install MariaDB

Install the MariaDB Server. The command will pull the necessary packages from the repository and install them automatically:

sudo dnf install mariadb-server -y
bash

Step 4: Start and enable MariaDB

After installation, start the MariaDB service:

sudo systemctl start mariadb
bash

Then, enable it to ensure MariaDB runs automatically after reboot:

sudo systemctl enable mariadb
bash

Check the current status of the service:

sudo systemctl status mariadb
bash

Step 5: Secure MariaDB

MariaDB includes a security setup script. Run mariadb_secure_installation to secure the installation:

sudo mariadb_secure_installation
bash

The script will prompt you to set a root password, remove anonymous users, disable remote root logins and delete the test database. Confirm each step with y to apply the recommended defaults.

Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flexibility with no minimum contract
  • 24/7 expert support included

Step 6: Test the database connection

Open the MariaDB console to verify access:

sudo mariadb -u root -p
bash

Enter the root password you just set. If you see the database shell, the installation was successful and MariaDB is ready to use:

Welcome to the MariaDB monitor...
MariaDB [(none)]>
sql

Step 7: Configure the firewall

To allow external connections, open port 3306 on the firewall:

sudo firewall-cmd --permanent --add-service=mysql
sudo firewall-cmd --reload
bash

This enables incoming connections on the MariaDB/MySQL port.

Step 8: Create a database and user

Log back in to MariaDB again to create a new database and user:

sudo mariadb -u root -p
bash

Then run the following commands:

CREATE DATABASE example_db;
CREATE USER 'user'@'localhost' IDENTIFIED BY 'safepassword';
GRANT ALL PRIVILEGES ON example_db.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
sql

You now have a database and a new user with full privileges.

Step 9: Enable remote access

If you need to allow other systems to connect over the network, edit the configuration file:

sudo vi /etc/my.cnf.d/mariadb-server.cnf
bash

Find the bind-address line and change it to:

bind-address = 0.0.0.0
bash

This enables connections from all IP addresses. Restart the service for the change to take effect:

sudo systemctl restart mariadb
bash
Was this article helpful?
Go to Main Menu