How to install MariaDB 10 on AlmaLinux 8 or Rocky Linux

MariaDB is a popular SQL database forked from MySQL. It was developed after Oracle acquired Sun Microsystems in 2010. MariaDB is primarily compatible with MySQL and can mostly replace MySQL without problems (it is API compatible). The processor architectures x86 and AMD64 are supported.

MariaDB uses the “storage engine” XtraDB as a replacement for InnoDB. Alphanumeric fields in heap tables can exceed 256 characters. Support of Pool of Threads to guarantee high speed even with 200,000+ connections.

This tutorial will teach us how to install and secure MariaDB on AlmaLinux and Rocky Linux 8.

MariaDB installation on Rocky and AlmaLinux 8

Step 1: Add Repository for MariaDB

The packages available to install MariaDB from the AlmaLinux or Rocky system repository provide version 8. Therefore, to get the latest 10.5, we need to manually add its official repository to the system. For that run-

sudo dnf install nano -y
sudo nano /etc/yum.repos.d/mariadb.repo

Copy and paste the following block of text in the file.

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1 

Save the file by pressing Ctrl+X, typing Y, and hitting the Enter key.

 

Step 2: Run AlmaLinux/Rocky system update

Now, to make sure all the system packages are up to date and also to refresh the repository cache, run the update command-

sudo dnf update

 

Step 3: Command to install MariaDB on AlmaLinux 8 or Rocky

The repository we need is at its place, now we can run the regular DNF command to install the server and client package of MariaDB on our AlmaLinux. Here is the command for that:

sudo dnf install MariaDB-server

 

Step 4:  Start and Enable MariaDB Services

Once the installation is completed, start the service of the Database server and then enable the same, so that it could start itself automatically with the system reboot.

sudo systemctl enable --now mariadb

To check everything is working as it should be, you can check the status of the MariaDB service using the command-

sudo systemctl status mariadb

 

Step 5: Secure the Database Server

Let’s run the command to make MariaDB secure by changing few settings such as password, removing the default database, disabling remote root access to the database, and more…

sudo mysql_secure_installation
mariaDB mysql secure installation

 

Step 6: Connect the Database server

To connect and create databases, type:

mysql -u root -p

 

 

2 thoughts on “How to install MariaDB 10 on AlmaLinux 8 or Rocky Linux”

  1. One suggested update/tip: Never, ever, ever, ever open MySQL (3306/tcp) to the wide internet like suggested. At a minimum, use a more advanced firewall rule that requires a valid source IP, even still that’s pushing the “bare minimum” of security.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.