Skip to main content

Step-by-Step Guide to Installing MariaDB on AlmaLinux 9

Even new businesses or applications can generate enough data to require a dedicated data handling and management system. This system should efficiently manage, store, and retrieve data for various processes and components.

MariaDB, a high-performance and versatile relational database management system (RDBMS), is a leading choice for its speed, reliability, and ease of use.

By leveraging MariaDB, businesses can streamline their data operations, enhance efficiency, and make informed decisions based on accurate and accessible data.

In this tutorial, we will discuss how to install MariaDB on AlmaLinux 9, a community-driven version of the enterprise-level Red Hat Enterprise Linux (RHEL).

Let us quickly examine the prerequisites and then go into the details of the installation process.

The Prerequisites

Before you dive into the installation process, ensure you have the following:

  • You have AlmaLinux 9 installed and running on your machine.
  • A user account with sudo or root privileges

Let us discuss the steps in detail.

Step #1: Update System Package Repository

Before the installation process, it’s crucial to update your system package repository to ensure all packages are up-to-date.

# sudo dnf update -y

Here, the -y flag automatically answers YES to any prompts, streamlining the update process.

The command ensures you have the latest security updates and software improvements.

Step #2: Install MariaDB

AlmaLinux 9 provides a MariaDB package directly in its official repositories. To install the MariaDB server with all necessary dependencies, execute the following command:

# sudo dnf install mariadb-server -y

Step #3: Start and Enable the MariaDB Service

Once you have installed the MariaDB package, start and enable the service to launch automatically on the system boot.

# sudo systemctl start mariadb

# sudo systemctl enable mariadb

Press enter or click to view image in full size

Step #4: Secure MariaDB Installation

It’s important to enhance the security of your MariaDB installation by setting a strong root password, removing anonymous users, disallowing remote root login, and removing test databases.

Join Medium for free to get updates from this writer.


Use the security script provided by MariaDB to secure the installation. Start by launching the script with this command:

# sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, and remove test databases. This step enhances the security of your database server.

Step #5: Configure MariaDB (Optional)

If you need to customize MariaDB settings based on your specific requirements and system resources, open the configuration file in a text editor like Vi or Nano.

# sudo vi /etc/my.cnf.d/mariadb-server.cnf

Press enter or click to view image in full size

You can adjust settings like max_connections and innodb_buffer_pool_size according to your system’s capabilities and your requirements.

Step #6: Test MariaDB

To verify if MariaDB is installed appropriately and running, connect to the MariaDB server using the following command:

# mysql -u root -p

Press enter or click to view image in full size