RHEL BasedRocky Linux

How To Install MariaDB on Rocky Linux 10

Install MariaDB on Rocky Linux 10

In this tutorial, we will show you how to install MariaDB on Rocky Linux 10. MariaDB represents one of the most reliable and feature-rich database management systems available today. This open-source relational database management system (RDBMS) serves as a drop-in replacement for MySQL, offering enhanced performance, improved security features, and comprehensive enterprise-grade capabilities. Rocky Linux 10, being the latest enterprise-grade Linux distribution that maintains Red Hat Enterprise Linux compatibility, provides an ideal environment for hosting MariaDB database servers.

The combination of MariaDB and Rocky Linux creates a powerful foundation for web applications, data analytics platforms, and enterprise database solutions. Whether you’re deploying a simple web application or managing complex data workloads, understanding how to properly install and configure MariaDB on Rocky Linux 10 ensures optimal database performance and security.

This comprehensive guide walks you through every aspect of MariaDB installation on Rocky Linux 10, from initial system preparation to advanced configuration techniques. You’ll learn multiple installation methods, security best practices, performance optimization strategies, and troubleshooting solutions that will help you create a robust database environment.

Understanding MariaDB and Rocky Linux

What is MariaDB?

MariaDB stands as a community-driven fork of MySQL, developed by the original MySQL team to maintain open-source principles and innovation. This relational database management system offers significant advantages over traditional MySQL installations, including enhanced storage engines, improved query optimization, and advanced security features.

The database system supports multiple storage engines simultaneously, allowing developers to choose the most appropriate engine for specific use cases. MariaDB’s InnoDB storage engine provides ACID compliance, foreign key constraints, and crash recovery capabilities, making it suitable for mission-critical applications.

Modern MariaDB versions include NoSQL capabilities through dynamic columns and JSON support, enabling hybrid database architectures that combine relational and document-based data models. These features make MariaDB particularly attractive for contemporary web applications that require flexible data structures.

Rocky Linux Overview

Rocky Linux emerged as a community-driven enterprise Linux distribution following CentOS’s transition to CentOS Stream. This distribution maintains binary compatibility with Red Hat Enterprise Linux (RHEL), ensuring stability and reliability for production environments.

The operating system provides long-term support cycles, security updates, and enterprise-grade features that make it ideal for database servers. Rocky Linux’s package management system, based on DNF (Dandified YUM), offers reliable software installation and dependency resolution capabilities.

For database administrators, Rocky Linux provides consistent performance, predictable behavior, and extensive documentation that simplifies database deployment and maintenance tasks.

Prerequisites and System Requirements

Before installing MariaDB on Rocky Linux 10, ensure your system meets specific requirements and prerequisites. Proper preparation prevents installation conflicts and ensures optimal database performance.

System Requirements

Rocky Linux 10 requires minimum hardware specifications to support MariaDB effectively. Allocate at least 2GB RAM for basic MariaDB operations, though production environments typically require 4GB or more depending on workload characteristics.

Storage requirements vary based on expected database size and transaction volume. Plan for adequate disk space that accommodates database files, transaction logs, and backup storage. SSD storage significantly improves database I/O performance compared to traditional hard drives.

Network connectivity remains essential for package downloads and repository access during installation. Ensure your system can reach external repositories or configure local mirrors if internet access is restricted.

User Privileges and Access

Installation requires root privileges or a user account with sudo access. Create a non-root user with appropriate permissions if you haven’t already configured administrative access.

Verify current user privileges by executing basic administrative commands. This verification step prevents permission-related installation failures and ensures smooth setup procedures.

Security Considerations

Configure firewall rules before installation to control database access. Rocky Linux includes firewalld by default, which provides comprehensive network security management capabilities.

SELinux configuration may require adjustments depending on your security policies and application requirements. Understand current SELinux modes and policies to prevent access conflicts after MariaDB installation.

Installation Methods Overview

Rocky Linux 10 offers multiple MariaDB installation approaches, each with distinct advantages and considerations. Understanding these methods helps you choose the most appropriate installation strategy for your specific requirements.

Default Repository Installation

The default Rocky Linux repositories include MariaDB packages that integrate seamlessly with the operating system. This approach provides stability and compatibility but may not offer the latest MariaDB features or versions.

Default repository installation typically includes MariaDB 10.11 or similar versions that have been tested extensively with Rocky Linux 10. These versions prioritize stability over cutting-edge features, making them suitable for production environments requiring proven reliability.

Official MariaDB Repository Installation

MariaDB Foundation maintains official repositories that provide the latest stable releases and advanced features. This method requires additional configuration steps but offers access to newer versions and enhanced capabilities.

Official repositories include multiple MariaDB versions, allowing you to select specific releases based on application compatibility requirements. These repositories receive frequent updates and security patches directly from MariaDB developers.

Method 1: Installing from Default Rocky Linux Repositories

The simplest MariaDB installation method uses Rocky Linux’s default package repositories. This approach minimizes configuration complexity while providing a stable database environment.

Step 1: System Update

Begin by updating your Rocky Linux system to ensure all packages are current and compatible. This preparation step prevents dependency conflicts during MariaDB installation.

sudo dnf update -y

The update process downloads and installs security patches, bug fixes, and package updates. Allow sufficient time for this process, especially on systems with many installed packages.

Monitor the update progress and address any conflicts or errors that occur during the process. Most updates complete successfully, but occasional package conflicts may require manual intervention.

Step 2: Package Installation

Install MariaDB server and client packages using the DNF package manager. The installation command automatically resolves dependencies and configures necessary components.

sudo dnf install mariadb mariadb-server -y

This command installs both the MariaDB server daemon and client tools required for database administration. The -y flag automatically confirms installation prompts, streamlining the setup process.

DNF downloads packages from configured repositories and installs them with appropriate file permissions and configurations. The process typically completes within a few minutes, depending on network speed and system performance.

Step 3: Installation Verification

Verify successful installation by checking the installed MariaDB version and package status. This verification confirms that all components installed correctly and are ready for configuration.

mariadb --version

The version command displays detailed MariaDB build information, including version number, architecture, and compilation details. Record this information for future reference and troubleshooting purposes.

Method 2: Installing from Official MariaDB Repository

Installing from official MariaDB repositories provides access to the latest features and versions. This method requires additional configuration but offers enhanced capabilities and frequent updates.

Step 1: Repository Configuration

Create a MariaDB repository configuration file to enable access to official packages. This configuration tells DNF where to find MariaDB packages and how to verify their authenticity.

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

Add the following repository configuration for Rocky Linux 10:

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

This configuration enables the MariaDB 10.11 repository with GPG verification for security. Adjust the version number if you prefer a different MariaDB release.

Step 2: GPG Key Import

Import MariaDB’s GPG signing key to verify package authenticity and integrity. This security measure prevents installation of modified or malicious packages.

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

GPG key verification ensures that downloaded packages come from official MariaDB sources and haven’t been tampered with during transmission.

Step 3: Repository Update

Refresh DNF’s package cache to include the new MariaDB repository. This step makes official MariaDB packages available for installation.

sudo dnf clean all && sudo dnf makecache

The cache refresh process downloads package metadata from all configured repositories, including the newly added MariaDB repository.

Step 4: MariaDB Installation

Install MariaDB packages from the official repository using DNF. The installation process automatically handles dependencies and configuration files.

sudo dnf install MariaDB-server MariaDB-client -y

Note the capital letters in package names when installing from official repositories. This naming convention distinguishes official packages from distribution-provided versions.

Starting and Configuring MariaDB Service

Proper service configuration ensures MariaDB starts automatically and operates reliably. Rocky Linux uses systemd for service management, providing comprehensive control over database operations.

Service Management

Start the MariaDB service immediately and enable automatic startup at boot time. These commands ensure database availability after system restarts.

sudo systemctl start mariadb
sudo systemctl enable mariadb

The systemctl enable command creates symbolic links that automatically start MariaDB during system boot. This configuration prevents database unavailability after server maintenance or unexpected restarts.

Service Status Verification

Check MariaDB service status to confirm successful startup and identify any configuration issues. Proper status verification helps diagnose problems before they affect applications.

sudo systemctl status mariadb

A healthy MariaDB service displays “active (running)” status with recent startup timestamps. Error messages in the status output indicate configuration problems that require attention.

Configuration File Locations

MariaDB uses multiple configuration files to control behavior and performance settings. Understanding these file locations helps with customization and troubleshooting tasks.

The primary configuration file /etc/my.cnf contains global MariaDB settings. Additional configuration files in /etc/my.cnf.d/ provide modular configuration management capabilities.

Securing MariaDB Installation

MariaDB installations require security hardening to protect against unauthorized access and data breaches. The included security script addresses common vulnerabilities and implements best practices.

Running mysql_secure_installation

Execute the MariaDB security script to configure essential security settings. This interactive script guides you through critical security decisions and implements secure defaults.

sudo mysql_secure_installation

The security script presents several configuration options that significantly impact database security. Each option addresses specific security concerns and should be carefully considered.

Security Configuration Steps

Root Password Configuration: Set a strong root password for database administration. Choose complex passwords that include uppercase letters, lowercase letters, numbers, and special characters.

  • Anonymous User Removal: Remove anonymous database accounts that allow unauthorized access. Anonymous users create security vulnerabilities that attackers can exploit.
  • Remote Root Access: Disable remote root login to prevent network-based attacks against the root account. Root access should only be available from localhost for security reasons.
  • Test Database Removal: Delete the default test database that provides unnecessary access to all users. Test databases often contain sample data that reveals database structure information.
  • Privilege Table Reload: Refresh MariaDB’s privilege tables to activate all security changes immediately. This step ensures that new security settings take effect without requiring service restarts.

Additional Security Measures

Configure firewall rules to control network access to MariaDB services. Rocky Linux’s firewalld provides comprehensive port and service management capabilities.

sudo firewall-cmd --permanent --add-service=mysql
sudo firewall-cmd --reload

These commands allow MySQL/MariaDB traffic through the firewall while maintaining protection against unauthorized access attempts.

Consider implementing SSL/TLS encryption for database connections, especially when applications connect over networks. Encrypted connections protect sensitive data during transmission between applications and databases.

Testing MariaDB Installation

Thorough testing verifies that MariaDB installation completed successfully and functions correctly. Testing procedures help identify configuration issues before deploying production applications.

Database Connection Testing

Connect to MariaDB using the command-line client to verify authentication and basic functionality. Successful connections confirm that the database server accepts client requests.

mysql -u root -p

Enter the root password configured during the security installation process. Successful authentication displays the MariaDB prompt, indicating ready database availability.

Basic Database Operations

Execute fundamental SQL commands to verify database functionality and performance. These tests confirm that MariaDB can create, modify, and query data effectively.

SHOW DATABASES;
CREATE DATABASE test_installation;
USE test_installation;
CREATE TABLE test_table (id INT PRIMARY KEY, name VARCHAR(50));
INSERT INTO test_table VALUES (1, 'Test Entry');
SELECT * FROM test_table;
DROP DATABASE test_installation;

These commands test essential database operations including database creation, table management, data insertion, and querying capabilities.

System Database Verification

Examine MariaDB’s system databases to ensure proper installation and configuration. System databases contain critical metadata and configuration information.

SHOW DATABASES;

Healthy MariaDB installations display several system databases including information_schema, mysql, performance_schema, and sys. Missing system databases indicate installation problems that require investigation.

Post-Installation Configuration

Optimize MariaDB configuration for your specific workload and performance requirements. Proper configuration significantly impacts database performance, stability, and resource utilization.

Performance Optimization

Memory Configuration: Adjust memory allocation settings based on available system RAM and expected workload characteristics. Proper memory configuration prevents performance bottlenecks and system instability.

sudo nano /etc/my.cnf.d/server.cnf

Add performance-related configuration options:

[mysqld]
innodb_buffer_pool_size = 1G
max_connections = 200
query_cache_size = 64M
query_cache_type = 1

These settings optimize memory usage for typical web applications. Adjust values based on your specific hardware configuration and application requirements.

Connection Management: Configure connection limits and timeout values to prevent resource exhaustion. Proper connection management ensures stable database performance under varying load conditions.

User Management

Create dedicated database users for applications instead of using the root account. Application-specific users provide better security and access control capabilities.

CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON application_db.* TO 'app_user'@'localhost';
FLUSH PRIVILEGES;

These commands create a limited-privilege user account suitable for application database access. Restrict user permissions to only necessary operations for enhanced security.

Backup Strategy Implementation

Configure automated backup procedures to protect against data loss. Regular backups provide recovery options in case of hardware failures, corruption, or accidental data deletion.

MariaDB includes the mariadb-backup utility for comprehensive backup operations. This tool creates consistent backups without interrupting database operations.

sudo mariadb-backup --backup --target-dir=/var/mariadb/backup/ --user=root --password=your_password

Schedule regular backups using cron jobs or systemd timers to ensure consistent data protection.

Common Issues and Troubleshooting

Database installations occasionally encounter problems that require systematic troubleshooting approaches. Understanding common issues and solutions helps resolve problems quickly and effectively.

Installation Problems

Repository Connection Issues: Network connectivity problems may prevent package downloads during installation. Verify internet connectivity and DNS resolution before retrying installation procedures.

Package Dependency Conflicts: Conflicting packages sometimes prevent successful MariaDB installation. Use DNF’s dependency resolution features to identify and resolve package conflicts.

sudo dnf install mariadb mariadb-server --best --allowerasing

The --best and --allowerasing flags help resolve complex dependency conflicts automatically.

Service Issues

Service Startup Failures: MariaDB may fail to start due to configuration errors or resource constraints. Examine systemd logs to identify specific startup problems.

sudo journalctl -u mariadb -f

This command displays real-time MariaDB service logs that reveal startup errors and configuration issues.

Port Conflicts: Other services may occupy MariaDB’s default port (3306), preventing database startup. Identify conflicting services and resolve port assignments appropriately.

sudo netstat -tulpn | grep :3306

Connection Problems

  • Authentication Failures: Incorrect passwords or user configurations prevent database connections. Verify user accounts, passwords, and access permissions when connection attempts fail.
  • Network Connectivity Issues: Firewall rules or network configuration may block database connections. Check firewall settings and network routing when remote connections fail.
  • Socket Connection Errors: Unix socket permission problems can prevent local database connections. Verify socket file permissions and ownership when local connections fail.

Upgrading and Maintenance

Regular maintenance ensures optimal MariaDB performance and security. Establish maintenance procedures that include updates, optimization, and monitoring activities.

Version Upgrades

Plan MariaDB version upgrades carefully to minimize downtime and prevent compatibility issues. Test upgrades in development environments before applying them to production systems.

Create comprehensive backups before performing version upgrades. Backup procedures provide recovery options if upgrades encounter unexpected problems.

Regular Maintenance Tasks

Database Optimization: Execute periodic optimization procedures to maintain query performance and storage efficiency. Regular optimization prevents performance degradation over time.

OPTIMIZE TABLE table_name;
ANALYZE TABLE table_name;

Log Rotation Management: Configure log rotation to prevent log files from consuming excessive disk space. Proper log management maintains system stability while preserving diagnostic information.

Security Updates: Apply security patches promptly to address vulnerabilities and maintain system security. Regular updates protect against known security threats and exploit attempts.

Monitor MariaDB security advisories and apply relevant patches based on your installation and configuration.

Advanced Configuration and Performance Tuning

Maximize MariaDB performance through advanced configuration techniques and optimization strategies. These adjustments help database systems handle increased workloads and provide consistent response times.

Storage Engine Optimization

Configure InnoDB settings for optimal performance based on workload characteristics. InnoDB serves as MariaDB’s default storage engine and benefits from careful tuning.

[mysqld]
innodb_buffer_pool_size = 70% of available RAM
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = ON

These settings optimize InnoDB for typical web application workloads. Adjust values based on specific performance requirements and hardware configurations.

Query Optimization

Enable and configure the query cache to improve performance for repeated queries. Query caching reduces CPU usage and improves response times for frequently executed statements.

Monitor slow query logs to identify performance bottlenecks and optimization opportunities. Slow query analysis helps optimize problematic queries and improve overall database performance.

Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing the MariaDB database server on your Rocky Linux 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