Blog

03/06/2019

How To Install MariaDB on RHEL 8



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

kbd { display: inline-block; margin: 0 .1em; padding: .1em .6em; font-family: Arial,”Helvetica Neue”,Helvetica,sans-serif; font-size: 11px; line-height: 1.4; color: #242729; text-shadow: 0 1px 0 #FFF; background-color: #e1e3e5; border: 1px solid #adb3b9; border-radius: 3px; box-shadow: 0 1px 0 rgba(12,13,14,0.2), 0 0 0 2px #FFF inset; white-space: nowrap;}

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 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.

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

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:
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 connect to the MariaDB database nixcraft using vivek account

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

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.

(adsbygoogle = window.adsbygoogle || []).push({});

Posted by: SXI ADMIN

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.

20/08/2019

Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...
14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....