Red Hat Enterprise Linux 7 (RHEL 7) and CentOS 7 were released back in 2014, and has support until 2024 when it reaches end-of-life. The CentOS Project follows releases of upstream RHEL source code with community binary builds a few months later. MariaDB Database Server can be installed on both RHEL 7 and CentOS 7 Linux servers. MariaDB is an open source and successful database project created from MySQL. It enjoys support from hundreds to thousands of open source contributors, and some companies.
In this guide, we shall be performing an installation of MariaDB 10.7 on CentOS 7 / RHEL 7 Linux system. Please note this is a single node database server setup using MariaDB. If you’re interested in a highly available deployment, consider using MariaDB Galera Cluster setup.
Some good features available in MariaDB 10.7 includes;
- New UUID Data Type – There is a new UUID data type aimed at the storage of 128-bit UUID (Universally Unique Identifier) data.
- Natural Sort – To be used in ordering of strings in alphabetical order
- Updates in InnoDB – New improvements and features in the MariaDB InnoDB storage engine
- Addition of Provider Plugins – There are five provider plugins (bzip2, lzma, lz4, lzo, snappy) for compression functionalities.
- New SFORMAT function
- InnoDB Bulk Insert – In bulk insert, pre-sort and build indexes one page at a time
- Password Reuse – The password_reuse_check plugin is a new password validation plugin
- Diagnostics Property – Used to identify the affected row
- Among many other new features, improvements and deprecations.
Install MariaDB 10.7 on CentOS 7 / RHEL 7
Follow the steps provided in the next sections to perform a working installation ofMariaDB 10.7 on CentOS 7 / RHEL 7 Linux machine. Ensure you’re not running any other MySQL based database management system, else uninstallation has to be performed prior to this setup.
Step 1) Add MariaDB YUM repository
A MariaDB YUM repository for RHEL based systems is available and can be added by running the following commands:
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --mariadb-server-version=10.7
The script executed automates the configuration of MariaDB repositories for YUM and the importation of all required GPG keys.
[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 ~
~
[info] Successfully added trusted package signing keys
[info] Cleaning package cache...
Loaded plugins: fastestmirror
Cleaning repos: base droplet-agent extras mariadb-main mariadb-maxscale mariadb-tools updates
Cleaning up list of fastest mirrors
We can confirm if the repository was added successfully by listing all available repos.
$ sudo yum makecache
$ sudo yum repolist
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.constant.com
* extras: mirror.math.princeton.edu
* updates: centos.mirror.constant.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base 10072
droplet-agent/x86_64 DigitalOcean Droplet Agent 7
extras/7/x86_64 CentOS-7 - Extras 500
mariadb-main MariaDB Server 42
mariadb-maxscale MariaDB MaxScale 4
mariadb-tools MariaDB Tools 15
updates/7/x86_64 CentOS-7 - Updates 3175
repolist: 13815
Step 2) Install MariaDB 10.7 on CentOS 7 / RHEL 7
After the addition of repository, we can proceed with the installation of MariaDB 10.7 on CentOS 7 / RHEL 7.
sudo yum install MariaDB-server MariaDB-client MariaDB-backup
Confirm the version of MariaDB server and client packages being installed and proceed if okay.
Dependencies Resolved
======================================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================================
Installing:
MariaDB-backup x86_64 10.7.1-1.el7.centos mariadb-main 6.9 M
MariaDB-client x86_64 10.7.1-1.el7.centos mariadb-main 14 M
MariaDB-compat x86_64 10.7.1-1.el7.centos mariadb-main 2.2 M
replacing mariadb-libs.x86_64 1:5.5.65-1.el7
MariaDB-server x86_64 10.7.1-1.el7.centos mariadb-main 25 M
Installing for dependencies:
MariaDB-common x86_64 10.7.1-1.el7.centos mariadb-main 81 k
boost-program-options x86_64 1.53.0-28.el7 base 156 k
galera-4 x86_64 26.4.9-1.el7.centos mariadb-main 9.6 M
libaio x86_64 0.3.109-13.el7 base 24 k
libpmem x86_64 1.5.1-2.1.el7 base 59 k
lsof x86_64 4.87-6.el7 base 331 k
pcre2 x86_64 10.23-2.el7 base 201 k
perl x86_64 4:5.16.3-299.el7_9 updates 8.0 M
perl-Carp noarch 1.26-244.el7 base 19 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-Encode x86_64 2.51-7.el7 base 1.5 M
perl-Exporter noarch 5.68-3.el7 base 28 k
perl-File-Path noarch 2.09-2.el7 base 26 k
perl-File-Temp noarch 0.23.01-3.el7 base 56 k
perl-Filter x86_64 1.49-3.el7 base 76 k
perl-Getopt-Long noarch 2.40-3.el7 base 56 k
perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PathTools x86_64 3.40-5.el7 base 82 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
perl-Pod-Escapes noarch 1:1.04-299.el7_9 updates 52 k
perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k
perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k
perl-Pod-Usage noarch 1.63-3.el7 base 27 k
perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k
perl-Socket x86_64 2.010-5.el7 base 49 k
perl-Storable x86_64 2.45-3.el7 base 77 k
perl-Text-ParseWords noarch 3.29-4.el7 base 14 k
perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k
perl-Time-Local noarch 1.2300-2.el7 base 24 k
perl-constant noarch 1.27-2.el7 base 19 k
perl-libs x86_64 4:5.16.3-299.el7_9 updates 690 k
perl-macros x86_64 4:5.16.3-299.el7_9 updates 44 k
perl-parent noarch 1:0.225-244.el7 base 12 k
perl-podlators noarch 2.5.1-3.el7 base 112 k
perl-threads x86_64 1.87-4.el7 base 49 k
perl-threads-shared x86_64 1.43-6.el7 base 39 k
socat x86_64 1.7.3.2-2.el7 base 290 k
Transaction Summary
======================================================================================================================================================================================================
Install 4 Packages (+42 Dependent packages)
Total download size: 72 M
Is this ok [y/d/N]: y
You can query more information about installed version of MariaDB database with the rpm command.
$ rpm -qi MariaDB-server
Name : MariaDB-server
Version : 10.7.1
Release : 1.el7.centos
Architecture: x86_64
Install Date: Sat Dec 4 12:10:25 2021
Group : Applications/Databases
Size : 127388696
License : GPLv2
Signature : DSA/SHA1, Sat Nov 6 21:58:58 2021, Key ID cbcb082a1bb943db
Source RPM : MariaDB-server-10.7.1-1.el7.centos.src.rpm
Build Date : Fri Nov 5 22:15:36 2021
Build Host : centos74-amd64
Relocations : (not relocatable)
Vendor : MariaDB Foundation
URL : http://mariadb.org
....
Step 3) Start and Secure MariaDB 10.7 onCentOS 7 / RHEL 7
Let’s start the database service after a successful installation:
$ sudo systemctl enable --now mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
Confirm status is running;
$ systemctl status mariadb
● mariadb.service - MariaDB 10.7.1 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 Sat 2021-12-04 12:16:38 UTC; 14s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 16703 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 16676 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_POSI>
Process: 16674 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 16687 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 16 (limit: 49496)
Memory: 68.0M
CGroup: /system.slice/mariadb.service
└─16687 /usr/sbin/mariadbd
...
Version of Client can be checked using the following command:
$ mariadb -V
mariadb Ver 15.1 Distrib 10.7.1-MariaDB, for Linux (x86_64) using readline 5.
Run mariadb-secure-installation
script which helps you secure your MariaDB database server
$ 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
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none): <ENTER>
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password: <INPUT-PASSWORD>
Re-enter new password: <CONFIRM-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!
Access to MariaDB shell should only be possible with a password
$ mysql -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.7.1-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.7.1-MariaDB |
+----------------+
1 row in set (0.000 sec)
Step 4) Create a test database/user in MariaDB
We can create a test database with the command below:
MariaDB [(none)]> CREATE DATABASE mydb;
Query OK, 1 row affected (0.001 sec)
Check if the database has been created by showing all available databases.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| mydb |
+--------------------+
5 rows in set (0.000 sec)
You should now have a successful installation of MariaDB 10.7 on CentOS 7 / RHEL 7 server or Desktop machine. In case of any issues encountered during installation, don’t hesitate to let us know in the comments section.
Good Udemy Learning courses:
- The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert
- Learn Database Design with MySQL
- SQL – MySQL for Data Analytics and Business Intelligence
- SQL for Beginners: Learn SQL using MySQL and Database Design
- MySQL, SQL and Stored Procedures from Beginner to Advanced
- The Complete MySQL Developer Course
- MySQL Database Administration: Beginner SQL Database Design