Skip to main content

How to install MariaDB 10.6 on Rocky Linux 8.4

Overview

MariaDB is one of the most widely deployed open-source relational databases globally that also have NoSQL features, make it more Acceptable and Significant. It is a community-driven and commercially supported fork of the MySQL relational database management system, intended to remain free and open-source software under the GNU General Public License.
In this tutorial, we will learn how to install MariaDB Community Server on Rocky Linux.

Lab Environment

The below table demonstrates the testing lab environment for installation of MariaDB Community Server on Rocky Linux:

Server MachineClient Machine
OS ReleaseRocky Linux release 8.4 (Green Obsidian)Red Hat Enterprise Linux release 8.4 (Ootpa)
Kernel4.18.0-305.10.2.el8_4.x86_644.18.0-305.7.1.el8_4.x86_64
MariaDB Release10.610.6
IP Address10.100.20.18110.100.20.198
HostnameServerClient
UsernameAdminUser
Table 01: Lab Environment

Step 1: Create MariaDB repository

In this tutorial, we will use the recommended method to use the official package repository. For this reason, we add the official repository to our system by executing the following script:

[Admin@Server ~]$ curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

Then update the server repository:

[Admin@Server ~]$ sudo dnf update -y

Now we can see the MariaDB official repository is added to our system:

[Admin@Server ~]$ sudo dnf repolist

Step 2: Install MariaDB packages

It is recommended to resolve some of the prerequisite packages’ dependencies before installing MariaDB on Rocky Linux. To install the prerequisite packages run the following command:

[Admin@Server ~]$ sudo dnf install perl-DBI libaio libsepol lsof boost-program-options rsync libpmem tar socat -y

If we do not assign the –repo tag in the installation command, there will be a chance to install MariaDB-server packages from our local repository that provides the OS vendor. To avoid it we need to use –repo tag. Now, run the following command to install the official MongoDB-server packages:

[Admin@Server ~]$ sudo dnf install --repo="mariadb-main" MariaDB-server -y

The main configuration file is /etc/my.cnf and the include directory of this file is /etc/my.cnf.d. And the default directory is /var/lib/mysql.

Step 3: Start MariaDB Instance

After successfully install start the MariaDB instance:

[Admin@Server ~]$ sudo systemctl start mariadb.service

To check the status of the service run the following command. The status will be running and active:

[Admin@Server ~]$ sudo systemctl status mariadb.service

To run the service automatically at boot time, we need to enable the service as below:

[Admin@Server ~]$ sudo systemctl enable mariadb.service

Step 4: Secure your deployment

The best practice is to ensure the recommended security before we start using the MariaDB database in the production environment, which ensures our deployment will meet the business-specific requirements and governance. To achieve this run the following command:

[Admin@Server ~]$ sudo mariadb-secure-installation

When the above command asked or prompted the user input, we will provide the following input:

Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Step 5: Connect locally to the MariaDB Instance

Within the MariaDB server, we can use the localhost and default port 3306 to connect locally with the help of mariadb utility:

[Admin@Server ~]$ mariadb -h localhost -p3306 -u root -p

Step 6: Connect remotely to the MariaDB Instance

For the security measures, the root user is not allowed to connect remotely. For this reason, we need to create a non-root user in the MariaDB database. So, locally connect to the MariaDB database that describes in the above and create a user named hr as following:

MariaDB [(none)]> CREATE USER hr@'%' IDENTIFIED BY 'p';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'hr'@'%' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;

Step 7: Install MariaDB-client on Client Machine

If we haven’t a MariaDB repository in our client machine, then we need to install it first. To achieve the purpose, add the repository by running the following command:

[User@Client ~]$ curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

Then update the repository of our client machine:

[User@Client ~]$ sudo dnf update --allowerasing -y

Now, time to install the MariaDB-Client packages on our client machine:

[User@Client ~]$ sudo dnf install MariaDB-client -y

Step 8: Configure MariaDB server to allowing remote connection

By default, loopback IP 127.0.0.1 is allowed for connecting to the instance that’s why other IPs will not be allowed to connect the instance. To allow the remote connection, we need to add the MariaDB server IP to the /etc/my.cnf.d/server.cnf file as bind-address:

[Admin@Server ~]$ sudo vim /etc/my.cnf.d/server.cnf

Find the below section, where we see the bind-address is comment.

# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0

So, comment out the bind-address and assign the MariaDB server IP:

# Allow server to accept connections on all interfaces.
#
bind-address=10.100.20.181

Here, the MariaDB server IP is 10.100.20.181. Now, this IP allows remote connectivity.

Another task is to add MariaDB port 3306 to the firewall:

[Admin@Server ~]$ sudo firewall-cmd --permanent --add-port=3306/tcp
[Admin@Server ~]$ sudo firewall-cmd --reload

Now restart the MariaDB service:

[Admin@Server ~]$ sudo systemctl restart mariadb.service

Now, we check the connectivity from our client machine:

[User@Client ~]$ mariadb -h 10.100.20.181 -p3306 -u hr -p

Step 7: Uninstall the MariaDB

Before uninstall, ensure we must back up our database and store it in another server for future restoration. Because complete uninstall erase everything from our server. To uninstall the package issue the following command:

[Admin@Server ~]$ sudo dnf remove --repo="mariadb-main" MariaDB-server -y

And lastly, remove the following directories:

[MongoDB@RockyLinuxServer ~]$ rm -rf /etc/my.cnf.d
[MongoDB@RockyLinuxServer ~]$ rm -rf /var/lib/mysql

Conclusion

In this tutorial, we learn how to install MariaDB 10.6 in the newborn Rocky Linux 8.4 in detail. Hope it will help you to install and configure MariaDB by yourself. If you have any questions or suggestions, please comment to me and for more tutorials visit my page.

References

In this tutorial, we follow the official docs as reference How to Install MariaDB Server on RHEL 8 / CentOS 8.

Comments

Popular posts from this blog

Upgrading Issue for RHEL 7 to 8 With Leapp

Overview The Leapp utility is a framework for updating and upgrading operating systems as well as applications. The operations of this utility consist of two phases 1. the preupgrade Phase – that chack the upgrade possibilities and 2. the actual upgrade phase – that map packages between previous and current versions of the software packages. Issue – 01: After running ‘ sudo leapp preupgrade ‘ sometimes you find the below issue in ‘ /var/log/leapp/leapp-report.txt ‘. Detail: Risk Factor: high (inhibitor) Title: Leapp detected loaded kernel drivers which have been removed in RHEL 8. Upgrade cannot proceed. Summary: Support for the following RHEL 7 device drivers has been removed in RHEL 8: – pata_acpi Key: f08a07da902958defa4f5c2699fae9ec2eb67c5b Remediation: 1. Disable detected kernel drivers in order to proceed with the upgrade process using the rmmod or modprobe -r . rmmod – Simple program to remove a module from the Linux Kernel modprobe – Add and remove modules from the Linux Ke...

Upgrading Oracle Linux 6 to 7

Overview It is possible to upgrade an Oracle Linux 6 system to Oracle Linux 7.6 under the following conditions: The system meets the minimum installation requirements for Oracle Linux 7 as described in Chapter 1, System Requirements and Limits. The Oracle Linux 6 system has been completely updated from the ol6_x86_64_latest channel or ol6_latest repository. UEK R3 or UEK R4 has been installed on the system to be upgraded and is the default boot kernel. Upgrading from UEK R2 is not supported. Note that the system is upgraded to use the UEK R5 release provided with Oracle Linux 7.6. Upgrading is supported only for systems that are installed with the Minimal Install base environment. If additional packages are installed from an alternative repository or channel, upgrade might fail or the resulting upgrade might not function as expected. reference: https://docs.oracle.com/en/operating-systems/oracle-linux/7/relnotes7.6/ol7-install.html#ol7-upgrade-ol6 Verifying the system before Upgrade: #...

Install Oracle Database 12c Release 2 On Red Hat 8

Overview According to Oracle, Oracle Database 12c is ‘the first database designed for the cloud’; the suffix ‘c’ stands for the cloud. There are many new features in this release such as multitenant architecture, pluggable database, in-memory, etc. The multitenant architecture is designed to simplify consolidation without requiring any changes to the applications. The rapid provisioning and portability capabilities are enhanced by the pluggable databases. Another new feature is in-memory makes it the first Oracle database to offer real-time analytics. This article describes the installation of Oracle Database 12c release 2 (12.2.0.1.0) 64-bit on Red Hat 8 64-bit. Lab Environment Server Machine Work Station or Client Machine OS Release Red Hat Enterprise Linux release 8.4 (Ootpa) Red Hat Enterprise Linux release 8.4 (Ootpa) Kernel 4.18.0-305.3.1.el8_4.x86_64 4.18.0-305.7.1.el8_4.x86_64 Release Oracle Database 12.1.0.2.0 Oracle SQL Developer Version 19.2.1.247 IP Address 192.168.201.116 ...