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:
- Open the terminal application. Another option is to log in using the ssh command
- Installing the MariaDB on RHEL 8, type:
sudo yum install mariadb-server
- Securing the MariaDB server in RHEL 8, run:
- 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.
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
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
How do I log in to the MariaDB server?
Use the mysql command as follows:
$ mysql -u root -p
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
$ mysql -u vivek -p nixcraft
For further information see:
- Create a MySQL Database, Tables and Insert Data
- Mysql User Creation: Setting Up a New MySQL User Account
- How to delete or remove a MySQL/MariaDB user account on Linux/Unix
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.