Installing MariaDB On RHEL 8
Installing MariaDB On RHEL 8
The Red Hat Enterprise Linux (RHEL) 8 Operating System release was replaced
MySQL with MariaDB as the default database system.
If your required application does not have any specific database requirements, you
Prerequisites
Before starting the process of installing MariaDB, make sure you have a RHEL 8
running system and a user to login into the system with sudo privileges.
Install MariaDB on RHEL 8
The default RHEL 8 repository providing MariaDB version 5.5, it is not the latest
To install MariaDB into RHEL 8, you need to follow the below process:
To install MariaDB 5.5 version into RHEL 8 by using the following Command:
Once the installation is complete, you can start the MariaDB service with:
Now that we have our service started, it is time to improve its security. We will
setup root password, disable remote root login, remove test database and
anonymous user. Finally we will reload all privileges.
For that purpose, simply run the following command and answer the questions
accordingly:
sudo mysql_secure_installation
Note that the root user’s password is empty, so if you want to change it,
simply press “enter”, when prompted for the current password. The rest you
can follow the steps and answers on the image below:
# mysql -u root -p
When prompted, enter the root password that you set earlier.
Now let’s create our database. For that purpose at the MariaDB prompt, run
the following command:
MariaDB [(none)]> CREATE DATABASE tecmint;
This will create new database named tecmint. Instead of accessing that
database with our root user, we will create separate database user, that will
have privileges to that database only.
We will create our new user called tecmint_user and grant it privileges on
the tecmint database, with the following command:
When creating your own user, make sure to replace “securePassword” with
the password you wish to give to that user.
When you have finished with the above commands, type “quit” at the prompt
to exit MariaDB:
Now you can use the new user to access the tecmint database.
# mysql -u tecmint_user -p
When prompted enter the password for that user. To change the used
database, you can use the following at the MariaDB prompt:
Alternatively, you can issue the mysql command by specifying the database
name as well as shown.
That way when you enter the user’s password, you will directly be using
the tecmint database.
You may get below the screen to import MariaDB GPG key
into the system:
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:
Installing MariaDB Server
The RHEL 8 and CentOS 8 distributions include MariaDB
Community Server 10.3.
$ wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
$ chmod +x mariadb_repo_setup
$ sudo ./mariadb_repo_setup
To avoid conflict with the OS-vendor packages, install
dependencies separately and use the --repo flag to specify the
repository:
MariaDB Server 10.3 and 10.4 write all data files and
tablespaces to a directory on the file system called the data
directory. After installing the packages, run
the mysql_install_db utility to provision this directory.
$ sudo mysql_install_db
Start the systemd service for MariaDB Server using systemctl:
$ sudo mysql_secure_installation