How To Install MariaDB on CentOS 8

I am a new to MariaDB server and CentOS 8 sysadmin. How do I install MariaDB on CentOS 8 Linux server using the yum command?

Introduction – MariaDB is a free and open-source database management system and acts as a drop replacement for the Oracle MySQL DB server. It is a community-driven and developed branch of Oracle MySQL server. MariaDB is a multi-user, multi-threaded SQL database server. This page explains how to install the latest stable version of MariaDB on CentOS 8 server.

How to install MariaDB on CentOS 8

The procedure to install MariaDB on a CentOS Enterprise Linux 8 is as follows:

  1. Open the terminal application. Another option is to log in using the ssh commandssh user@centos-8-server-ip
  2. Installing the MariaDB on CentOS 8, type:
    sudo yum install mariadb-server
  3. Securing the MariaDB server in CentOS 8, run:
    sudo mysql_secure_installation
  4. Finally test your installation by running:
    mysql -u root -p

Let us see all steps and commands in details.

Installing MariaDB on CentOS 8 using the yum command

One can search for MariaDB package using the following syntax:
sudo yum search mariadb

Want to find out MariaDB server version? Try:
sudo yum info mariadb
Sample outputs:

Last metadata expiration check: 0:37:22 ago on Tuesday 01 October 2019 02:35:21 PM UTC.
Installed Packages
Name         : mariadb
Epoch        : 3
Version      : 10.3.11
Release      : 2.module_el8.0.0+35+6f2527ed
Arch         : x86_64
Size         : 38 M
Source       : mariadb-10.3.11-2.module_el8.0.0+35+6f2527ed.src.rpm
Repo         : @System
From repo    : AppStream
Summary      : A very fast and robust SQL database server
URL          :
License      : GPLv2 with exceptions and LGPLv2 and BSD.
Description  : MariaDB is a community developed branch of MySQL - a multi-user, multi-threaded


Next type the following yum command to MariaDB version 10.3.11 on CentOS 8:
$ sudo yum install mariadb-server

How to enable mariadb.service at CentOS 8 server boot time

Run the following systemctl command:
$ sudo systemctl enable mariadb.service

Created symlink /etc/systemd/system/mysql.service ? /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service ? /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/ ? /usr/lib/systemd/system/mariadb.service.

How to start/stop/restart mariadb.service on CentOS 8

Again use the following syntax:
$ sudo systemctl stop mariadb.service
$ sudo systemctl start mariadb.service
$ sudo systemctl restart mariadb.service
$ sudo systemctl status mariadb.service

How to secure the MariaDB Server on CentOS 8

You must secure the MariaDB server by running the following command for production use:
$ sudo mysql_secure_installation

Securing the MariaDB Server on CentOS 8

How do I log in to the MariaDB server?

Use the mysql command as follows:
$ mysql -u root -p

Testing the MariaDB server installation

Above commands indicates the installation has been successful on CentOS 8 server or VM. You can now add users and create databases for your applications written in PHP, Perl, Python and more.

How to add database on the MariaDB server

First, log in as root user:
$ mysql -u root -p mysql
Create a new MariaDB database called blog1. Type the following command at MariaDB> prompt:

How to add users on the MariaDB server

Create a new user called tristan for database called blog1 (feel free to replace username and secretePasswordHere with actual password):
GRANT ALL ON blog1.* TO tristan@localhost IDENTIFIED BY 'secretePasswordHere';
List all database:
show databases;
Quit from MariaDB:

How to connect to the MariaDB database nixcraft using vivek account

$ mysql -u tristan -p'secretePasswordHere' blog1
$ mysql -u tristan -p blog1

For further information see:


You completed and secured MariaDB on CentOS 8 server. Further, you learned how to create users and databases on the MariaDB server. For more info see MariaDB site here and recommended MariaDB books here.

This entry is 1 of 5 in the Tutorial series. Keep reading the rest of the series:
  1. CentOS 8 install MariaDB
  2. OpenBSD install MariaDB database server
  3. RHEL 8 install MariaDB
  4. FreeBSD 11 install MariaDB
  5. Setup MariaDB SSL and secure connections from clients

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @