How to Install MariaDB 10.5 on Rocky Linux EL9 or EL8

MariaDB 10.5, the latest Long-Term Support release, is making waves in open-source databases. Offering many features tailored for businesses and developers, this version blends enhanced performance, security, and flexibility. This guide will walk you through the steps to install MariaDB 10.5 on Rocky Linux 9 or the older stable enterprise Linux release of Rocky Linux 8.

First, let’s dive into some of the significant changes the MariaDB 10.5 release historically brought in:

Performance Enhancements:

  • InnoDB as the Default Storage Engine: Supersedes MyISAM, resulting in better performance, crash recovery, and support for transactions.
  • ColumnStore Enhancements: Boosts performance through better data loading, improved compression, and support for multi-node deployments.

Security and User Management Improvements:

  • Password Rotation Policy: A measure to increase database security by mandating periodic password changes.
  • User Account Locking: Allows admins to lock or unlock user accounts, ensuring better access control.

Flexibility and Ease of Use:

  • Application Time Periods: Simplifies time-related data handling by allowing developers to define and query specific periods.
  • Enhanced SQL Mode: Offers more flexibility when dealing with invalid or ambiguous SQL statements.

For those eager to harness these advancements, we’ll guide you through the installation process for MariaDB 10.5 on Rocky Linux 9 or Rocky Linux 8 using MariaDB’s official repository.

Install MariaDB 10.5 on Rocky Linux 9 or 8

We aim to provide a detailed walkthrough for setting up MariaDB 10.5 using the official repository on a Rocky Linux system. Our objective is to empower you with a step-by-step procedure, explaining the rationale behind every action to ensure maximum clarity, even for those new to this realm. Let’s get started.

Step 1: Import Repository on Rocky Linux

First off, we need to secure the official repository for MariaDB 10.5. To accomplish this, we will be using the tee command, which will generate a new file titled mariadb.repo within the /etc/yum.repos.d/ directory. Here, the information about the repository will be securely stored.

In addition, we are also using the <<EOF command. Its role is to denote that we are about to insert a block of text spread over multiple lines. This block, in this scenario, contains the repository details necessary for our setup. This approach ensures that our setup for the MariaDB 10.5 repository is up and ready, with all packages backed by the proper GPG key for enhanced security.

sudo tee /etc/yum.repos.d/mariadb.repo<<EOF
# MariaDB 10.5 repository list - created 2023-04-12 00:30 UTC
name = MariaDB
baseurl =$releasever/$basearch

Step 2: Install MariaDB 10.5 on Rocky Linux 9 or 8

With our repository in place, we can now proceed to the next significant phase: installing MariaDB 10.5. Here is the command you need to use:

sudo dnf install MariaDB-server MariaDB-client

Make sure to input the command exactly as it appears, maintaining the given capitalization. This command takes the lead in installing the MariaDB server and client packages from the repository. As for functionality, the server package plays a critical role in managing the database system, while the client package comes equipped with the required tools for interacting with the MariaDB server.

Step 3: Checking Your MariaDB 10.5 Installation on Rocky Linux

After successfully installing MariaDB, it’s crucial to verify your installation. To confirm that everything is in order, use this command:

mariadb --version

This command responds by displaying the installed version and build information for MariaDB on your system. This crucial step allows you to ensure that you have, indeed, installed the correct version of MariaDB, specifically MariaDB 10.5.

Monitoring the Status of MariaDB 10.5 Service on Rocky Linux 9 or 8

Upon the successful installation of MariaDB on your Rocky Linux system, one crucial task remains – ensuring the MariaDB service is enabled. It’s worth noting that unlike certain Linux distributions, Rocky Linux does not automatically enable the MariaDB service post-installation. So, let’s dive into how you can enable and manage the MariaDB service effectively.

Activating the MariaDB Service

To kick things off, you need to enable the MariaDB service. Execute the following command to not only enable the service but also start it instantaneously.

sudo systemctl enable mariadb --now

This command is beneficial as it not only activates the MariaDB service but also ensures it begins operation immediately.

Verifying the Status of MariaDB Service

Now that the MariaDB service is enabled, the next step involves confirming that everything is working as expected. This can be accomplished by executing the following command:

systemctl status mariadb

On execution, this command returns the current status of the MariaDB service. In most instances, the status of the MariaDB service should be active. However, if that is not the case, you can manually start the MariaDB service.

Managing the MariaDB 10.5 Service on Rocky Linux

Efficient management of the MariaDB service includes the ability to start, stop, enable, or disable it as per your requirements. Here are the necessary commands that offer you full control over the service:

To initiate the MariaDB service:

sudo systemctl start mariadb

To halt the MariaDB service:

sudo systemctl stop mariadb

To have the MariaDB service automatically start during system boot-up:

sudo systemctl enable mariadb

To prevent the MariaDB service from automatically starting during system boot-up:

sudo systemctl disable mariadb

To restart the MariaDB service:

sudo systemctl restart mariadb

These commands collectively provide comprehensive control over the MariaDB service, allowing you to ensure the service is active when required and inactive during periods of non-use.

Enhance MariaDB 10.5 Security via Built-In Script on Rocky Linux 9 o8

Post the successful installation of MariaDB 10.5, enhancing its security should be a priority. An out-of-the-box MariaDB setup doesn’t necessarily cater to the optimum security standards, necessitating manual adjustments. Luckily, MariaDB comes with a dedicated security script that can be employed for this purpose, ensuring a fortified MariaDB setup.

Executing the Security Script for MariaDB 10.5 on Rocky Linux

To initiate the process, the security script bundled with MariaDB must be executed. The command required to do so is:

sudo mariadb-secure-installation

Upon successful execution, the script presents various prompts to guide you through securing your MariaDB installation. This includes defining the password for the root account, the elimination of any root accounts accessible from external networks, the removal of anonymous user accounts, and deletion of the test database, which is accessible to anonymous users by default.

As per security best practices, it is recommended to affirmatively respond, by typing ‘Y’, to the options for enhancing security.

Responding to the Security Script Prompts

In the course of the script execution, you will encounter various prompts requiring your response. For instance:

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y

Answering ‘Y’ to all the questions as shown above ensures you harness the maximum security benefits offered by the script, leading to a robust and secure MariaDB installation.

Managing MariaDB 10.5 with Rocky Linux 9 or 8

There might be times when you need to perform certain tasks beyond the basic MariaDB service operations. This could involve upgrading existing databases, or possibly even removing MariaDB 10.5 from your system. This section will guide you through those processes.

Upgrading Existing Databases

If you are hosting databases on your Rocky Linux server—be it for CMS platforms like WordPress or any other purpose—upgrading these databases becomes crucial when you transition to a newer MariaDB version. This ensures compatibility with the new database version.

To transition an existing database from MariaDB 10.3 or 10.4 to 10.5 on Rocky Linux, execute the following command:

sudo mysql_upgrade -u [username] -p

You should replace [username] with the actual database username, if applicable. Alternatively, if you’re operating as the root user, you can execute the command without providing a username:

sudo mysql_upgrade

This operation upgrades the existing MariaDB database to the latest version, allowing it to function smoothly with the newer MariaDB version.

Remove MariaDB 10.5 from Your Rocky Linux System

There could be scenarios where you may need to uninstall MariaDB 10.5 from your Rocky Linux system. To do so, you can execute the following command:

sudo dnf remove mariadb mariadb-server

This command will purge most unused dependencies linked with the MariaDB installation, assisting in decluttering your system. Lastly, you might consider removing the repository file with this command:

sudo rm /etc/yum.repos.d/mariadb.repo

Closing Thoughts

In conclusion, though detailed, installing MariaDB 10.5 on a Rocky Linux 9 or 8 system is quite straightforward once each step is understood and executed carefully. We covered various aspects of this process, including the basic installation, enabling and managing the service, bolstering security with a script, and even upgrading or uninstalling MariaDB, if need be. With this knowledge, you can confidently navigate your MariaDB installation, optimizing your Rocky Linux system to meet your specific database needs.

Leave a Comment