How to install MariaDB 10.4 on CentOS 8 / RHEL 8

How to install MariaDB 10.4 on CentOS 8 / RHEL 8 Linux machine? MariaDB is a multi-user, multi-threaded SQL database server derived from the MySQL relational database management system. It is designed to be fast, powerful, and has more advanced features to suit aggressive database operations.

We won’t discuss the great features of the MariaDB 10.4 database system, you can check the release notes for a detailed feature set. This is just the few steps required to have a working MariaDB 10.4 database server on a CentOS 8 / RHEL 8 Linux machine.

Install MariaDB 10.4 on CentOS 8 / RHEL 8

These are the ideal steps to go through when installing MariaDB 10.4 on a CentOS 8 / RHEL 8 Linux server.

Step 1: Update the system

If no critical services are running in production on the server, please update your system before starting to install MariaDB 10.4 on CentOS 8 / RHEL 8.

sudo dnf -y upgrade

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

Now we need to add the MariaDB yum repository to our CPU architecture. This guide will cover adding repositories for x86_64 CPU computers.

CentOS 8:

sudo tee /etc/yum.repos.d/MariaDB.repo<

RHEL 8:

sudo tee /etc/yum.repos.d/MariaDB.repo<

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

After adding the Yum repository, you can immediately install the MariaDB 10.4 repository to CentOS 8 / RHEL 8.

CentOS 8:

sudo dnf install boost-program-options
sudo dnf install MariaDB-server MariaDB-client --disablerepo=AppStream 
sudo systemctl start 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 start mariadb

When prompted, press ÿ 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

You can use the following command to query more details about the installed packages:

$ 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

The 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: Protect the MariaDB database server

MariaDB 10.4 is now installed on CentOS 8 / RHEL 8 and can be protected 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 the 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, please check:

Best MySQL Learning Books:

  • Murach's MySQL (3rd Edition)
  • MySQL (version 5) (developer library)
  • MySQL explained: Your step-by-step guide to database design
  • Getting Started with SQL-
    Beginner's hands-on method-simple, focused introduction
    Reading this will involve the actual meaning of SQL. Here, a reader
    Briefly introduce all the basics of the language;
  • Prioritize using SQL-your SQL mind-study guide;
  • SQL Cookbook: Query Solutions and Database Technologies for Database Developers-This book contains tips and tricks that can be used for daily database management;
  • Self-learning MS SQL Server-a rather old book that covers all aspects of SQL Server from a higher level;
  • Effective SQL
    An easy-to-read guide that explores SQL features. remember
    You may need some SQL knowledge to apply already existing ideas
    Layout.
Sidebar