AlmaLinuxRHEL Based

How To Install MariaDB on AlmaLinux 10

Install MariaDB on AlmaLinux 10

MariaDB stands as one of the most popular open-source relational database management systems available today, serving as a powerful and reliable alternative to MySQL. Developed by the original creators of MySQL, MariaDB offers enhanced performance, improved security features, and extensive compatibility with existing MySQL applications. AlmaLinux 10, being a stable and enterprise-ready Linux distribution, provides an excellent platform for hosting MariaDB installations in production environments.

This comprehensive guide will walk you through the complete process of installing MariaDB 11 on AlmaLinux 10, covering everything from initial system preparation to advanced security configurations. Whether you’re a system administrator, database developer, or DevOps engineer, you’ll find detailed instructions, troubleshooting tips, and best practices to ensure a successful MariaDB deployment.

MariaDB 11 introduces significant improvements over previous versions, including enhanced performance optimizations, better security features, and improved compatibility with modern applications. The combination of MariaDB 11 and AlmaLinux 10 creates a robust, scalable database solution suitable for both small applications and enterprise-level deployments.

Table of Contents

Prerequisites and System Requirements

Before beginning the MariaDB 11 installation process, ensure your AlmaLinux 10 system meets the necessary requirements for optimal database performance and stability.

Hardware Requirements

Your AlmaLinux 10 server should have a minimum of 1 GB RAM, though 2-4 GB is recommended for production environments. Allocate at least 10 GB of free disk space for the MariaDB installation and initial database storage. A 1GHz CPU processor provides sufficient computing power for basic installations, but multi-core processors are preferred for high-traffic applications.

Software and Access Requirements

Ensure you have root access or a non-root user account with sudo privileges on your AlmaLinux 10 system. SSH access to the server is essential for remote administration and maintenance tasks. Verify that your system has stable network connectivity for downloading packages and accessing external repositories during the installation process.

Security Considerations

Before proceeding with the installation, consider your network security requirements. Plan firewall configurations to restrict database access to authorized hosts and applications only. Understanding these prerequisites ensures a smooth installation process and helps prevent common configuration issues that may arise during or after the MariaDB setup.

System Preparation and Updates

Proper system preparation forms the foundation of a successful MariaDB installation. Begin by ensuring your AlmaLinux 10 system has the latest security patches and package updates installed.

Comprehensive System Update

Execute a complete system update using the DNF package manager to bring all installed packages to their latest versions:

sudo dnf update -y && sudo dnf upgrade -y

This command combination updates the package metadata and upgrades all installed packages to their newest available versions. The process may take several minutes depending on the number of packages requiring updates and your internet connection speed.

Cleaning Package Cache

After completing the system updates, clean the DNF package cache to free up disk space and ensure clean package installations:

sudo dnf clean all

Installing Development Tools

For comprehensive MariaDB functionality and potential future customizations, install the Development Tools package group:

sudo dnf groupinstall "Development Tools"

System Reboot Verification

Check if any kernel updates were installed that require a system reboot. If kernel updates are present, restart your system to ensure all changes take effect:

sudo systemctl reboot

After the reboot, verify that all services are running correctly and that the system is ready for the MariaDB installation process.

Installation Methods Overview

AlmaLinux 10 offers multiple approaches for installing MariaDB, each with distinct advantages depending on your specific requirements and use case scenarios.

Default Repository Installation

The AlmaLinux 10 default repositories include MariaDB packages, making installation straightforward using the standard DNF package manager. This method provides excellent integration with the operating system and automatic security updates through the standard AlmaLinux update channels.

Official MariaDB Repository Benefits

Installing from the official MariaDB repository ensures access to the latest MariaDB 11 features and security patches directly from the MariaDB development team. This approach typically provides newer versions than those available in the default AlmaLinux repositories and offers more granular control over specific MariaDB components and versions.

Choosing the Right Method

Select the default repository method for standard installations where long-term stability and automatic system updates are priorities. Choose the official MariaDB repository when you need the latest features, specific version control, or plan to use advanced MariaDB functionality not available in the default packages.

Method 1: Installation from Default AlmaLinux Repository

The default AlmaLinux repository provides a streamlined installation process for MariaDB, offering excellent system integration and simplified maintenance procedures.

Installing MariaDB Server and Client

Install the complete MariaDB server and client packages using a single DNF command:

sudo dnf install mariadb-server mariadb -y

This command installs both the MariaDB server daemon and the client tools necessary for database administration and application connectivity. The installation process automatically handles package dependencies and configures the basic system integration components.

Understanding Package Components

The mariadb-server package includes the core database engine, system tables, and configuration files required for running a MariaDB database server. The mariadb package provides client utilities such as the mysql command-line interface, mysqldump backup utility, and other essential database management tools.

Version Verification

After installation completion, verify the installed MariaDB version to confirm successful installation:

mysql -V

The expected output should display version information similar to:

mysql Ver 15.1 Distrib 10.11.9-MariaDB, for Linux (x86_64) using EditLine wrapper

Additional Package Options

Consider installing supplementary packages for enhanced functionality:

sudo dnf install mariadb-backup mariadb-common

These packages provide additional backup utilities and common configuration files that enhance the overall MariaDB experience and administrative capabilities.

Method 2: Installation from Official MariaDB 11 Repository

Installing from the official MariaDB repository provides access to the latest MariaDB 11 features and ensures you receive updates directly from the MariaDB development team.

Repository Configuration Setup

Create a new repository configuration file for MariaDB 11:

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

Add the following repository configuration, adapting the RHEL repository for AlmaLinux 10:

[mariadb]
name = MariaDB
baseurl = https://rpm.mariadb.org/11.8/rhel/9/$basearch
module_hotfixes = 1
gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1
enabled = 1

GPG Key Import and Verification

Import the MariaDB GPG signing key to verify package authenticity:

sudo rpm --import https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB

Module Management

Disable the default MariaDB module to prevent conflicts with the official repository packages:

sudo dnf module disable mariadb -y

Installing MariaDB 11 Packages

Install the specific MariaDB 11 packages from the official repository:

sudo dnf install MariaDB-server MariaDB-client MariaDB-backup -y

This installation method provides access to the latest MariaDB 11 features and ensures compatibility with the most recent database optimizations and security enhancements.

Package Verification

Confirm the successful installation and version by checking the installed MariaDB version:

mariadb --version

Service Management and Initial Configuration

Proper service management ensures MariaDB starts automatically and runs reliably on your AlmaLinux 10 system.

Starting MariaDB Service

Initiate the MariaDB database service using systemctl:

sudo systemctl start mariadb

Enabling Automatic Startup

Configure MariaDB to start automatically during system boot:

sudo systemctl enable mariadb

Service Status Verification

Check the current status of the MariaDB service to ensure proper operation:

sudo systemctl status mariadb

The expected output should show an active (running) status similar to:

● mariadb.service - MariaDB 10.11 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
   Active: active (running) since Sat 2025-03-28 13:42:38 CDT; 7s ago
   Main PID: 31307 (mariadbd)
   Status: "Taking your SQL requests now..."

Additional Service Commands

For ongoing service management, use these essential commands:

  • Restart MariaDB: sudo systemctl restart mariadb
  • Stop MariaDB: sudo systemctl stop mariadb
  • Reload configuration: sudo systemctl reload mariadb

Network Port Verification

Confirm MariaDB is listening on the default port 3306:

sudo netstat -tlnp | grep 3306

Security Hardening with mysql_secure_installation

Securing your MariaDB installation protects against unauthorized access and strengthens overall database security through the mysql_secure_installation script.

Executing the Security Script

Run the MariaDB security configuration script as root or with sudo privileges:

sudo mysql_secure_installation

Initial Password Configuration

For fresh installations, no root password is initially set. Press Enter when prompted for the current password:

Enter current password for root (enter for none):

Unix Socket Authentication

The script will prompt you to switch to unix_socket authentication for enhanced security:

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
... Success!

Root Password Configuration

Set a strong root password when prompted. Choose a complex password containing uppercase letters, lowercase letters, numbers, and special characters:

Set root password? [Y/n] Y
New password: 
Re-enter new password:

Removing Anonymous Users

Remove anonymous user accounts that pose security risks:

Remove anonymous users? [Y/n] Y
... Success!

Disabling Remote Root Login

Prevent remote root login to enhance security:

Disallow root login remotely? [Y/n] Y
... Success!

Test Database Removal

Remove the test database and associated privileges:

Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading Privilege Tables

Reload privilege tables to apply all security changes immediately:

Reload privilege tables now? [Y/n] Y
... Success!

Basic MariaDB Operations and Verification

After completing the installation and security configuration, verify MariaDB functionality through basic database operations and administrative tasks.

Accessing MariaDB Console

Log into the MariaDB console using the root account:

sudo mysql -u root -p

Enter the root password you configured during the security setup process.

Database Creation and Management

Create a test database to verify functionality:

CREATE DATABASE testdb;
SHOW DATABASES;
USE testdb;

User Account Creation

Create a dedicated user account for application access:

CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'SecurePassword123';
GRANT SELECT, INSERT, UPDATE, DELETE ON testdb.* TO 'dbuser'@'localhost';
FLUSH PRIVILEGES;

Basic Table Operations

Test table creation and data manipulation:

CREATE TABLE test_table (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(255)
);

INSERT INTO test_table (name, email) VALUES ('Test User', 'test@example.com');
SELECT * FROM test_table;

Configuration File Locations

Familiarize yourself with important MariaDB configuration files:

  • Main configuration: /etc/my.cnf or /etc/mysql/my.cnf
  • Server configuration: /etc/my.cnf.d/mariadb-server.cnf
  • Log files: /var/log/mariadb/mariadb.log

Troubleshooting Common Issues

Address frequent installation and configuration challenges that may occur during the MariaDB setup process.

Package Dependency Conflicts

If you encounter dependency conflicts during installation, resolve them by updating the package cache and checking for conflicting repositories:

sudo dnf clean all
sudo dnf makecache
sudo dnf check-update

Service Startup Failures

When MariaDB fails to start, examine the service logs for detailed error information:

sudo journalctl -u mariadb -f
sudo systemctl status mariadb -l

Common startup issues include insufficient disk space, permission problems, or configuration file syntax errors.

Permission and Ownership Issues

Ensure proper file ownership and permissions for MariaDB directories:

sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod 755 /var/lib/mysql

Configuration File Problems

Validate configuration file syntax using the MariaDB configuration test utility:

sudo mysqld --help --verbose

Memory and Performance Issues

Monitor system resources and adjust MariaDB configuration for optimal performance:

free -h
top -p $(pgrep mariadbd)

Network Connectivity Problems

Verify firewall settings and network configuration if remote connections fail:

sudo firewall-cmd --list-all
sudo netstat -tlnp | grep 3306

Best Practices and Maintenance

Implement ongoing maintenance procedures and security practices to ensure optimal MariaDB performance and reliability.

Regular Security Updates

Maintain current security patches through regular system updates:

sudo dnf update mariadb-server mariadb

Backup Strategy Implementation

Establish automated backup procedures using MariaDB backup utilities:

sudo mariadb-dump --all-databases > /backup/mariadb_backup_$(date +%Y%m%d).sql

Performance Monitoring

Implement monitoring solutions to track database performance metrics:

sudo mariadb -e "SHOW GLOBAL STATUS LIKE 'Questions%';"
sudo mariadb -e "SHOW GLOBAL STATUS LIKE 'Slow_queries%';"

User Account Management

Regularly review and maintain user accounts and privileges:

SELECT User, Host FROM mysql.user;
SHOW GRANTS FOR 'username'@'localhost';

Firewall Configuration

Configure firewall rules to restrict database access to authorized hosts only:

sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="3306" accept'
sudo firewall-cmd --reload

Log File Management

Implement log rotation and monitoring to maintain system performance:

sudo logrotate -f /etc/logrotate.d/mariadb

Advanced Configuration and Optimization

Fine-tune MariaDB settings for enhanced performance and specific use case requirements.

Memory Configuration Tuning

Optimize memory usage based on available system resources:

[mysqld]
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
key_buffer_size = 32M

Connection and Thread Management

Configure connection limits and thread handling:

[mysqld]
max_connections = 200
thread_cache_size = 16
table_open_cache = 2000

Security Enhancements

Implement additional security measures through configuration:

[mysqld]
bind-address = 127.0.0.1
skip-networking = false
ssl-cert = /etc/mysql/ssl/server-cert.pem
ssl-key = /etc/mysql/ssl/server-key.pem

Performance Schema Configuration

Enable performance monitoring for advanced troubleshooting:

[mysqld]
performance_schema = ON
performance_schema_max_table_instances = 400

Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing the MariaDB database server on your AlmaLinux OS 10 system. For additional help or useful information, we recommend you check the official MariaDB website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button