How To Install MariaDB 10.9 on AlmaLinux 9 | Easy Setup

Posted on

How To Install MariaDB 10.9 on AlmaLinux 9 | Easy Setup

How To Install MariaDB 10.9 on AlmaLinux 9 | Easy Setup

This guide, brought to you by Orcacore, aims to walk you through the process of How To Install MariaDB 10.9 on AlmaLinux 9. MariaDB, a community-developed fork of MySQL, stands as a leading open-source SQL (Structured Query Language) relational database management system. Crafted by the original developers of MySQL, MariaDB prioritizes speed, reliability, and ease of use. It’s a robust solution for managing data in a structured and efficient manner.

MariaDB has become the default MySQL-type database system in the standard repositories of most major Linux distributions, including RHEL (Red Hat Enterprise Linux) and Fedora Linux. Its compatibility extends beyond Linux, as it operates seamlessly on Windows, macOS, and numerous other operating systems. Widely adopted as a replacement for MySQL, MariaDB forms a crucial component of the popular LAMP (Linux + Apache + MariaDB + PHP) and LEMP (Linux + Engine-X + MariaDB + PHP) stacks, empowering web applications and services around the globe. This guide helps you How To Install MariaDB 10.9 on AlmaLinux 9.

Before proceeding, ensure you have access to an AlmaLinux 9 server and are logged in as a non-root user with sudo privileges. If you haven’t already, you can follow our guide on the Initial Server Setup with AlmaLinux 9.

1. Add MariaDB 10.9 Repository

The first step in installing MariaDB 10.9 is adding the official MariaDB repository to your AlmaLinux 9 system. This ensures you’re pulling the software from a trusted source. To achieve this, create a new repository file:

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

Next, insert the following content into the mariadb.repo file. This configuration tells your system where to find the MariaDB 10.9 packages.

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.9/rhel9-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Save the file and exit the editor. With the repository file in place, update your local package index to reflect the changes:

sudo dnf update -y

This command refreshes your system’s package list, incorporating the newly added MariaDB repository.

2. Install MariaDB 10.9 Server

Now that the repository is configured, you can proceed with the installation of the MariaDB 10.9 server. Use the following command to install the MariaDB server package:

sudo dnf install MariaDB-server -y

Once the installation is complete, start the MariaDB service and enable it to launch automatically at system boot:

sudo systemctl enable --now mariadb

To verify that MariaDB is running correctly, check its status:

sudo systemctl status mariadb

This command will display the current status of the MariaDB service, indicating whether it is active and running without errors.

Check your MariaDB status on AlmaLinux 9

3. Run MariaDB Secure Installation Script

After installation, it’s crucial to secure your MariaDB installation by running the mariadb-secure-installation script. This script guides you through several security-related configuration steps. Execute the following command:

sudo mariadb-secure-installation

The script will prompt you to set a root password for MariaDB. It will also ask a series of questions regarding security settings, such as removing anonymous users, disallowing remote root login, and removing the test database. Answer "yes" to these questions to enhance the security of your MariaDB server.

Once the script completes, you can access the MariaDB shell using the following command:

sudo mysql -u root -p

Enter the root password you set during the secure installation process when prompted. This will grant you access to the MariaDB command-line interface.

access your MariaDB shell

For more detailed information and advanced configuration options, refer to the MariaDB Documentation Page.

Conclusion

You have successfully learned How To Install MariaDB 10.9 on AlmaLinux 9 by adding the MariaDB 10.9 repository to your server and securing your installation by running the MariaDB secure script.

Hope you enjoy it. Please subscribe to us on Facebook, Instagram, and YouTube.

You may also like to read the following articles:

Install MariaDB on Debian 12 Bookworm

Upgrade MariaDB on AlmaLinux 9

Install MariaDB 10.11 on Ubuntu 22.04

Alternative Solutions for Installing MariaDB 10.9 on AlmaLinux 9

While the official MariaDB repository method is recommended, here are two alternative approaches to installing MariaDB 10.9 on AlmaLinux 9: using a containerization platform like Docker and utilizing Software Collections (SCL).

1. Installing MariaDB 10.9 using Docker

Docker allows you to run applications in isolated containers, ensuring consistency across different environments. This is useful if you want to avoid modifying the host system or if you need to run multiple versions of MariaDB simultaneously.

Explanation:

Docker containers package an application with all its dependencies, including libraries and runtime environments. This means you can install MariaDB 10.9 within a Docker container without affecting the system-level MariaDB installation (if any). This approach provides isolation and simplifies deployment.

Steps:

  1. Install Docker: If Docker is not already installed on your AlmaLinux 9 system, install it using the following commands:

    sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
    sudo systemctl start docker
    sudo systemctl enable docker
  2. Pull the MariaDB 10.9 Docker Image: Obtain the official MariaDB 10.9 Docker image from Docker Hub:

    sudo docker pull mariadb:10.9
  3. Run the MariaDB 10.9 Container: Create and run the MariaDB container with appropriate configurations. You’ll need to set an environment variable for the root password. Consider using a volume for persistent storage of the database.

    sudo docker run -d 
      --name mariadb109 
      -e MYSQL_ROOT_PASSWORD=your_root_password 
      -v mariadb_data:/var/lib/mysql 
      -p 3306:3306 
      mariadb:10.9
    • -d: Runs the container in detached mode (in the background).
    • --name mariadb109: Assigns a name to the container for easy management.
    • -e MYSQL_ROOT_PASSWORD=your_root_password: Sets the MariaDB root password. Replace your_root_password with your desired password.
    • -v mariadb_data:/var/lib/mysql: Creates a named volume mariadb_data and mounts it to /var/lib/mysql inside the container. This ensures that your database data is persisted even if the container is stopped or removed.
    • -p 3306:3306: Maps port 3306 on the host to port 3306 inside the container. This allows you to connect to the MariaDB server from your host machine.
    • mariadb:10.9: Specifies the Docker image to use.
  4. Connect to the MariaDB Server: You can now connect to the MariaDB server running inside the Docker container using a MariaDB client on your host machine:

    mysql -u root -p -h 127.0.0.1

    You’ll be prompted for the root password you set earlier.

2. Installing MariaDB 10.9 using Software Collections (SCL)

Software Collections allow you to install multiple versions of software on the same system without conflicts. This can be useful for testing or development purposes. Note that SCL is typically used for older versions and might not be the most straightforward approach for MariaDB 10.9 on AlmaLinux 9, but is theoretically possible if a suitable SCL package becomes available in the future.

Explanation:

SCL creates a separate environment for the installed software, preventing it from interfering with the system’s default packages. This is achieved by using a different directory structure and environment variables.

Steps (Conceptual – Requires a Suitable SCL Package):

  1. Install the scl-utils package:

    sudo dnf install scl-utils -y
  2. Find a Suitable MariaDB 10.9 SCL Package (Hypothetical): You would need to find an SCL package specifically built for MariaDB 10.9 on AlmaLinux 9. This is the biggest challenge with this approach, as such a package may not exist. If it did, it might be named something like mariadb109-scl.

  3. Install the MariaDB 10.9 SCL Package (Hypothetical):

    sudo dnf install mariadb109-scl -y
  4. Enable the SCL Environment: To use MariaDB 10.9 installed via SCL, you need to enable the corresponding environment.

    scl enable mariadb109-scl bash

    This command opens a new shell session with the MariaDB 10.9 environment activated.

  5. Connect to the MariaDB Server (Hypothetical): The exact command to connect would depend on how the SCL package is configured. It might be similar to the standard mysql command. You’d need to consult the SCL package’s documentation for specific instructions.

Important Considerations for SCL:

  • Finding a suitable SCL package for MariaDB 10.9 on AlmaLinux 9 might be difficult or impossible.
  • SCL packages often require specific configuration and documentation that you need to follow carefully.

In conclusion, while Docker provides a reliable and isolated environment, SCL depends on the availability of suitable packages and might require more complex configuration. The official repository method remains the most straightforward and recommended approach for installing How To Install MariaDB 10.9 on AlmaLinux 9. These alternative methods offer different advantages, but require careful planning and execution.

Leave a Reply

Your email address will not be published. Required fields are marked *