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 repos­i­to­ry 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 ad­van­tages of MariaDB on RHEL 9?

MariaDB delivers high per­for­mance and re­li­a­bil­i­ty. RHEL 9 provides a stable, secure operating system with long-term support. Combined, the two create a robust database en­vi­ron­ment that is both main­tain­able and easy to manage over time.

What are the re­quire­ments for in­stalling MariaDB on RHEL 9?

Before starting the in­stal­la­tion, make sure your system meets these re­quire­ments:

  • RHEL 9 installed
  • Root priv­i­leges or access via sudo
  • At least 1 GB RAM (2 GB is rec­om­mend­ed)
  • At least 2 GB of free disk space
Managed Databases
Time-saving database services
  • En­ter­prise-grade ar­chi­tec­ture managed by experts
  • Flexible solutions tailored to your re­quire­ments
  • Leading security in ISO-certified data centers

How to install MariaDB on RHEL 9

If you need a re­la­tion­al database on RHEL 9, MariaDB can be set up quickly and reliably. On a standard RHEL 9 system, the in­stal­la­tion process itself is pretty straight­for­ward.

Step 1: Update the system

Before in­stalling any packages, update your system to the latest version. This prevents conflicts with outdated de­pen­den­cies.

sudo dnf update -y
sudo dnf upgrade -y
bash

Step 2: Add the MariaDB repos­i­to­ry

RHEL 9 typically provides an older version of MariaDB. To install the latest release, add the official repos­i­to­ry. Create a new con­fig­u­ra­tion 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 repos­i­to­ry and install them au­to­mat­i­cal­ly:

sudo dnf install mariadb-server -y
bash

Step 4: Start and enable MariaDB

After in­stal­la­tion, start the MariaDB service:

sudo systemctl start mariadb
bash

Then, enable it to ensure MariaDB runs au­to­mat­i­cal­ly 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_in­stal­la­tion to secure the in­stal­la­tion:

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 rec­om­mend­ed defaults.

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

Step 6: Test the database con­nec­tion

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 in­stal­la­tion was suc­cess­ful and MariaDB is ready to use:

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

Step 7: Configure the firewall

To allow external con­nec­tions, open port 3306 on the firewall:

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

This enables incoming con­nec­tions 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 priv­i­leges.

Step 9: Enable remote access

If you need to allow other systems to connect over the network, edit the con­fig­u­ra­tion 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 con­nec­tions from all IP addresses. Restart the service for the change to take effect:

sudo systemctl restart mariadb
bash
Go to Main Menu