How To Install MariaDB 10.8 on CentOS 8 / RHEL 8

Posted on 17 views

How can I install MariaDB 10.8 on CentOS 8 / RHEL 8 Linux machine?. MariaDB is a multi-user, multi-threaded SQL database server forked from the MySQL relational database management system. It was designed to be fast, robust and with more advanced features fit for aggressive database operations.

We won’t discuss the cool features of MariaDB 10.8 database system, you can check the release notes for a detailed feature set coverage. Here are just the mere steps required to have a working MariaDB database server on CentOS 8 / RHEL 8 Linux machine.

Install MariaDB 10.8 on CentOS 8 / RHEL 8

These are the ideal steps you’ll go through when installing MariaDB 10.8 on CentOS 8 / RHEL 8 Linux server.

Step 1: Update System

If you don’t have any critical services running in Production on the server, update the system before you begin installation of MariaDB on CentOS 8 / RHEL 8.

sudo dnf -y upgrade

Step 2: Add MariaDB 10.8 repository to CentOS 8 / RHEL 8

We now need to add the MariaDB yum repository for our CPU architecture. This guide will cover adding repository for a x86_64 CPU machine.

CentOS 8:

curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --mariadb-server-version=10.8

RHEL 8:

curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --mariadb-server-version=10.8

Expected output from execution:

[info] Checking for script prerequisites.
[info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo
[info] Adding trusted package signing keys...
/etc/pki/rpm-gpg /home/rocky
/home/rocky
[info] Successfully added trusted package signing keys
[info] Cleaning package cache...
39 files removed

Step 3: Install MariaDB 10.8 repository to CentOS 8 / RHEL 8

After adding Yum repository, you can proceed to install MariaDB repository to CentOS 8 / RHEL 8 straight away.

sudo dnf install boost-program-options -y
sudo dnf module reset mariadb -y
sudo yum install MariaDB-server MariaDB-client MariaDB-backup -y
sudo systemctl enable --now mariadb

When prompted, press to accept installation:

Transaction Summary
======================================================================================================================================================================================================
Install  13 Packages

Total download size: 61 M
Installed size: 285 M
Is this ok [y/N]: y

More details on installed package can be queried using:

$ rpm -qi MariaDB-server
Name        : MariaDB-server
Version     : 10.8.6
Release     : 1.el8
Architecture: x86_64
Install Date: Thu 17 Nov 2022 10:06:05 AM UTC
Group       : Applications/Databases
Size        : 126585350
License     : GPLv2
Signature   : DSA/SHA1, Sat 05 Nov 2022 02:53:19 AM UTC, Key ID cbcb082a1bb943db
Source RPM  : MariaDB-server-10.8.6-1.el8.src.rpm
Build Date  : Thu 03 Nov 2022 12:25:02 PM UTC
Build Host  : rhel8-amd64
Relocations : (not relocatable)
Vendor      : MariaDB Foundation
URL         : http://mariadb.org
Summary     : MariaDB database server binaries
...

Start and enable MariaDB service

sudo systemctl enable --now mariadb

Status should show as running:

$ systemctl status mariadb
● mariadb.service - MariaDB 10.6.4 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Tue 2021-10-19 11:19:36 UTC; 6s ago
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 737887 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 737861 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POS>
  Process: 737859 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 737871 (mariadbd)
   Status: "Taking your SQL requests now..."
    Tasks: 15 (limit: 49496)
   Memory: 68.0M
   CGroup: /system.slice/mariadb.service
           └─737871 /usr/sbin/mariadbd

Step 4: Secure MariaDB Database Server

Now that MariaDB is installed on CentOS 8 / RHEL 8, secure it by running mysql_secure_installation.

$ sudo mariadb-secure-installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Test access to database shell:

$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.8.6-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT version();
+-----------------+
| version()       |
+-----------------+
| 10.8.6-MariaDB  |
+-----------------+
1 row in set (0.000 sec)

MariaDB [(none)]> QUIT
Bye
coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.