How To Install MariaDB on RHEL 8

I am a new MariaDB user and RHEL 8 system adminstrator. How do I install MariaDB on RHEL 8 server using the yum command?

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

How to install MariaDB on RHEL 8

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

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

Let us see all steps in details.

Installing MariaDB on RHEL 8 using the yum command

Type the following yum command:
$ sudo yum install mariadb-server

How to enable mariadb.service at RHEL 8 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 RHEL 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

Click to enlarge

How to secure the MariaDB Server on RHEL 8

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

Securing the MariaDB Server

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 RHEL 8 server. 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 nixcraft. Type the following command at MariaDB> prompt:

How to add users on the MariaDB server

Create a new user called vivek for database called nixcraft:
GRANT ALL ON nixcraft.* TO vivek@localhost IDENTIFIED BY 'secretePasswordHere';

How to connect to the MariaDB database nixcraft using vivek account

$ mysql -u vivek -p'secretePasswordHere' nixcraft
$ mysql -u vivek -p nixcraft

For further information see:


You completed and secured MariaDB on RHEL 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 3 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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig 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.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum