Home MySQL How to Install and Secure MariaDB in RHEL 8.5

How to Install and Secure MariaDB in RHEL 8.5

MariaDB is a reputable and open-source relational database management system, that offers invaluable database solutions to numerous users around the operating system ecosystem.

Since it is a MySQL fork, it has earned a community-developed status. The latter statement implies that MariaDB has growing community user support for individuals that are new to the database software or seek its advanced knowledge base and application.

Ensure you have sudo/root user privileges on the RHEL 8 system you are using.

Installing MariaDB in RHEL Linux

As a Linux operating system rule of thumb, always ensure that your Linux system is up-to-date before the installation or configuration of any software package.

$ sudo yum update && sudo yum upgrade -y 

Next, install the MariaDB database server on your RHEL 8 system.

$ sudo yum install mariadb-server 

Confirm that you want to install the MariaDB database server by responding to the [y/n] prompt which will then initiate its installation on your RHEL system.

Install MariaDB in RHEL Linux
Install MariaDB in RHEL Linux

After the installation process finishes, you can proceed to start, enable and verify the status of MariaDB from your terminal. Enabling this RDBMS ensures that it keeps on running even after a successful system reboot.

$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ sudo systemctl status mariadb  
Check MariaDB Status in RHEL
Check MariaDB Status in RHEL

You can check on MariaDB’s installed version by running the command:

$ mysql --version 
Check MariaDB Version in RHEL
Check MariaDB Version in RHEL

Securing MariaDB in RHEL Linux

With its successful installation, we need to run the following security script to secure the installation of MariaDB.

$ sudo mysql_secure_installation 

The above command will help you configure critical steps like root database user password which is defaulted to blank, remove anonymous user, disallow root login remotely, remove test the database, and reload privilege tables.

Secure MariaDB in RHEL Linux
Secure MariaDB in RHEL Linux

The next step is to log in to your MariaDB database using the root user password you created.

$ mysql -u root -p 
Connect MariaDB Shell
Connect MariaDB Shell

From here, you can create a database user that you can assign database roles:

MariaDB [(none)]> CREATE USER linuxshelltips@localhost IDENTIFIED BY "Your_preferred_db_user_password";

We can also create a random database and demonstrate how this user can have control over it.

MariaDB [(none)]> CREATE DATABASE linuxshelltips_db;

To assign the created database user full control over this database and all its associated database tables, we will execute the command:

MariaDB [(none)]> GRANT ALL ON linuxshelltips_db.* TO linuxshelltips@localhost;

Flush privileges and exit the MariaDB console.

MariaDB [(none)]> FLUSH PRIVILEGES:
MariaDB [(none)]> exit 
Create Database User Roles
Create Database User Roles

This article has demonstrated how to install the MariaDB database server, configure root database user credentials, create a random database user, and assign this user control over a randomly created database.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.