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.
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
You can check on MariaDB’s installed version by running the command:
$ mysql --version
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.
The next step is to log in to your MariaDB database using the root user password you created.
$ mysql -u root -p
From here, you can create a database user that you can assign database roles:
MariaDB [(none)]> CREATE USER [email protected] 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 [email protected];
Flush privileges and exit the MariaDB console.
MariaDB [(none)]> FLUSH PRIVILEGES: MariaDB [(none)]> exit
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.