You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

How can I install MariaDB 10.4 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.4 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 10.4 database server on CentOS 8 / RHEL 8 Linux machine.

Install MariaDB 10.4 on CentOS 8 / RHEL 8

These are the ideal steps you’ll go through when installing MariaDB 10.4 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 10.4 on CentOS 8 / RHEL 8.

sudo dnf -y upgrade

Step 2: Add MariaDB 10.4 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:

sudo tee /etc/yum.repos.d/MariaDB.repo<<EOF 
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

RHEL 8:

sudo tee /etc/yum.repos.d/MariaDB.repo<<EOF 
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/rhel8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

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

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

CentOS 8:

sudo dnf install boost-program-options
sudo dnf install MariaDB-server MariaDB-client --disablerepo=AppStream 
sudo systemctl enable --now mariadb

RHEL 8:

sudo dnf install boost-program-options
sudo dnf install MariaDB-server MariaDB-client --disablerepo=rhel-8-for-x86_64-appstream-rpms 
sudo systemctl enable --now mariadb

When prompted, press y to accept installation:

MariaDB                                    186 kB/s | 489 kB     00:02    
Last metadata expiration check: 0:00:01 ago on Sat 04 Jan 2020 08:37:41 PM EAT.
Dependencies resolved.
========================================================================================================================================================
 Package                               Arch                          Version                                       Repository                      Size
========================================================================================================================================================
Installing:
 MariaDB-client                        x86_64                        10.4.11-1.el8                                 mariadb                         12 M
 MariaDB-server                        x86_64                        10.4.11-1.el8                                 mariadb                         26 M
Installing dependencies:
 MariaDB-common                        x86_64                        10.4.11-1.el8                                 mariadb                         87 k
 galera-4                              x86_64                        26.4.3-1.rhel8.0.el8                          mariadb                         13 M

Transaction Summary
========================================================================================================================================================
Install  4 Packages

Total download size: 51 M
Installed size: 196 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.4.11
Release     : 1.el8
Architecture: x86_64
Install Date: Sat 04 Jan 2020 08:38:56 PM EAT
Group       : Applications/Databases
Size        : 129705129
License     : GPLv2
Signature   : DSA/SHA1, Wed 11 Dec 2019 02:08:56 AM EAT, Key ID cbcb082a1bb943db
Source RPM  : MariaDB-server-10.4.11-1.el8.src.rpm
Build Date  : Tue 10 Dec 2019 06:19:51 PM EAT
Build Host  : rhel8-amd64
Relocations : (not relocatable)
Vendor      : MariaDB Foundation
URL         : http://mariadb.org
Summary     : MariaDB: a very fast and robust SQL database server
Description :
MariaDB: a very fast and robust SQL database server

It is GPL v2 licensed, which means you can use the it free of charge under the
conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/).

MariaDB documentation can be found at https://mariadb.com/kb
MariaDB bug reports should be submitted through https://jira.mariadb.org

Start and enable MariaDB service

sudo systemctl enable --now mariadb

Status should show as running:

$ systemctl status mariadb
● mariadb.service - MariaDB 10.4.11 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 2020-01-04 20:40:50 EAT; 15s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 31317 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 11512)
   Memory: 73.4M
   CGroup: /system.slice/mariadb.service
           └─31317 /usr/sbin/mysqld

Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] InnoDB: 10.4.11 started; log sequence number 60972; transaction id 21
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] InnoDB: Buffer pool(s) load completed at 200104 20:40:50
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] Plugin 'FEEDBACK' is disabled.
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] Server socket created on IP: '::'.
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] Reading of all Master_info entries succeeded
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] Added new Master_info '' to hash table
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: 2020-01-04 20:40:50 0 [Note] /usr/sbin/mysqld: ready for connections.
Jan 04 20:40:50 centos8.novalocal mysqld[31317]: Version: '10.4.11-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
Jan 04 20:40:50 centos8.novalocal systemd[1]: Started MariaDB 10.4.11 database server.

Step 4: Secure MariaDB Database Server

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

$ sudo mysql_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.4.11-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.4.11-MariaDB |
+-----------------+
1 row in set (0.000 sec)

MariaDB [(none)]> QUIT
Bye

Want to master MySQL, check:

Best MySQL Study books:

  • Getting Started With SQL – A Hands-On Approach for Beginners – a simple, to-the-point introductory read that’ll touch on the practical implications of SQL. Here, a reader gets introduced concisely to all the basics of the language;
  • Head First SQL – Your Brain on SQL – A Learner’s Guide;
  • SQL Cookbook: Query Solutions and Database Techniques for Database Developers – a book is full of hacks and tips that can be applied in day-to-day database management;
  • Teach Yourself MS SQL Server – a fairly old book, yet, it covers all the aspects of SQL Server on a high level;
  • Effective SQL – an easy-to-read guide book that explores SQL features. Keep in mind that you might need some SQL knowledge to apply the ideas that have been laid out.
You can support us by downloading this article as PDF from the Link below. Download the guide as PDF