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 re­pos­it­ory 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­vant­ages of MariaDB on RHEL 9?

MariaDB delivers high per­form­ance and re­li­ab­il­ity. RHEL 9 provides a stable, secure operating system with long-term support. Combined, the two create a robust database en­vir­on­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­stall­a­tion, make sure your system meets these re­quire­ments:

  • RHEL 9 installed
  • Root priv­ileges or access via sudo
  • At least 1 GB of RAM (2 GB is re­com­men­ded)
  • At least 2 GB of free storage 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
  • Hosted in the UK under strict data pro­tec­tion le­gis­la­tion

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­stall­a­tion process itself is fairly 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­pend­en­cies.

sudo dnf update -y
sudo dnf upgrade -y
bash

Step 2: Add the MariaDB re­pos­it­ory

RHEL 9 typically provides an older version of MariaDB. To install the latest release, add the official re­pos­it­ory. Create a new con­fig­ur­a­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 re­pos­it­ory and install them auto­mat­ic­ally:

sudo dnf install mariadb-server -y
bash

Step 4: Start and enable MariaDB

After in­stall­a­tion, start the MariaDB service:

sudo systemctl start mariadb
bash

Then, enable it to ensure MariaDB runs auto­mat­ic­ally 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­stall­a­tion to secure the in­stall­a­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 accept the re­com­men­ded defaults.

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­stall­a­tion was suc­cess­ful and MariaDB is ready for 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 account with full priv­ileges.

Step 9: Enable remote access

If you need to allow other systems to connect over the network, edit the con­fig­ur­a­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 any IP address. Restart the service for the change to take effect:

sudo systemctl restart mariadb
bash
Go to Main Menu