How to Install MariaDB on Red Hat Enterprise Linux 7 Operating System

MariaDB is the latest open source and popular relational database management system, compatible and replacement of MySQL.
MariaDB developed with MySQL original developers and many people from the community.
 
The Red Hat Enterprise Linux (RHEL) 7 Operating System release was replaced MySQL with MariaDB as the default database system.

In this tutorial article, we will show how to install MariaDB into CentOS, but for any reason you want to install MySQL into your CentOS, you can check the How to install MySQL on RHEL 7 tutorial.

If your required application does not have any specific database requirements, you should go with MariaDB, default database of RHEL 7 Operating System.

Prerequisites

Before starting the process of installing MariaDB, make sure you have a RHEL 7 running system and a user to login into the system with sudo privileges.

Install MariaDB on RHEL 7

The default RHEL 7 repository providing MariaDB version 5.5, it is not the latest version of MariaDB, but it is a stable release.

To install MariaDB into RHEL 7, you need to follow the below process:

Step 1 – Install MariaDB

To install MariaDB 5.5 version into RHEL 7 by using the following Command:

$ sudo yum install mariadb-server
Step 2 – Start MariaDB Service
 
After installation of MariaDB, the service automatically started, but you can use below command for manually start the MariaDB service:
$ sudo systemctl start mariadb
Step 3 – Enable MariaDB Service
 
You should enable the MariaDB service to make MariaDB service auto start on system startup, by using the following command:
$ sudo systemctl enable mariadb
Step 4 – Verify MariaDB
 
To verify the MariaDB service, you can check the status of the service by using the following command:
$ sudo systemctl status mariadb
Step 5 – MariaDB Secure Installation
 
To secure the MariaDB installation like change root password, restrict root access to localhost, remove test database, etc. to perform this task, you should run this command:
$ sudo mysql_secure_installation

Install Latest MariaDB on RHEL 7

The latest MariaDB server version 10.3 is not coming with default repository of RHEL 7. If you want to install the latest version of MariaDB into RHEL 7 system, create MariaDB repository file to install the latest MariaDB directly from official repository of MariaDB packages.

Let’s start the installation process of MariaDB 10.3 into RHEL 7 by the following procedure:

Step 1 – Enable MariaDB Repository
 
To enable MariaDB repository into a CentOS system, you need to create a repository file into /etc/yum.repos.d/ directory, as you can see below, we have created MariaDB repository file with the name of MariaDB.repo, you should also create the same file into your system.
Step 2 – Install MariaDB Server and Client
 
After creating the repository file, you should update your system’s repository package list by using the following command:
$ sudo yum update

Once the CentOS package is updated, you can use the following command to install mariaDB Server and Client:

$ sudo yum install MariaDB-server MariaDB-client

You may get below the screen to import MariaDB GPG key into the system:

You should type Y (yes) to allow to download the key file.

Step 3 – Enable and start the MariaDB Service
 
Once the installation of MariaDB completed, you should enable and start the service, as shown below:
$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb
Step 4 – Verify MariaDB installation
 
You can verify the MariaDB installation by checking the status of service using the following command:
$ sudo systemctl status mariadb
Step 5 – MariaDB Secure Installation
 
After installation and running service need to make your MariaDB secure, and to perform the security operation need to execute mysql_secure_instalaltion script, as shown below:
$ sudo mysql_secure_installation
This script will use to set the password for root, restrict root user to localhost, remove anonymous users, and remove test database, etc.
 
All step will appear on the screen with detailed, and you need to press Y as your answer to accept the security changes.

MariaDB connection from CLI

To connect MariaDB server using terminal or CLI with root user credential type the below command:
$ mysql –u root –p
Now it will ask you to enter a password for the root user and press enter.
 
Once you logged in into MariaDB shell and you will get a screen like below:

Conclusion

In this acritical, we learned how to install MariaDB into RHEL 7 system. We also learned to install MariaDB directly from MariaDB repository.

Now MariaDB is installed in your system successful, and you know how to connect with MariaDB shell to perform Database commands and operations.

0 Comments

Submit a Comment

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

three − three =

Related Articles