How to install MariaDB on RHEL 9
MariaDB can be installed on RHEL 9 in just a few steps:
- Update RHEL 9 to the latest version
- Set up the MariaDB repository and configure the database server
- Install and start MariaDB
- Secure the database and configure the firewall
- 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
- 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 -ybashStep 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.repobashThen 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=1bashClear the package cache and rebuild it:
sudo dnf clean all
sudo dnf makecachebashStep 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 -ybashStep 4: Start and enable MariaDB
After installation, start the MariaDB service:
sudo systemctl start mariadbbashThen, enable it to ensure MariaDB runs automatically after reboot:
sudo systemctl enable mariadbbashCheck the current status of the service:
sudo systemctl status mariadbbashStep 5: Secure MariaDB
MariaDB includes a security setup script. Run mariadb_secure_installation to secure the installation:
sudo mariadb_secure_installationbashThe 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.
- 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 -pbashEnter 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)]>sqlStep 7: Configure the firewall
To allow external connections, open port 3306 on the firewall:
sudo firewall-cmd --permanent --add-service=mysql
sudo firewall-cmd --reloadbashThis 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 -pbashThen 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;sqlYou 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.cnfbashFind the bind-address line and change it to:
bind-address = 0.0.0.0bashThis enables connections from all IP addresses. Restart the service for the change to take effect:
sudo systemctl restart mariadbbash
