I am a new MariaDB and RHEL 8 user. 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 command
    ssh 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 install MariaDB on RHEL 8

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/multi-user.target.wants/mariadb.service ? /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

Start the MariaDB service with the systemct on RHEL 8
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
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
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:
CREATE DATABASE nixcraft;

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 create the MariaDB users and database

How to connect to the MariaDB database nixcraft using vivek account

$ mysql -u vivek -p'secretePasswordHere' nixcraft
OR
$ mysql -u vivek -p nixcraft
How to connect to the MariaDB server using user account
For further information see:

Conclusion

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.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Similar Posts