How To Install MySQL on AlmaLinux 10
MySQL stands as one of the most popular open-source relational database management systems worldwide, powering millions of applications from small websites to enterprise-level platforms. When combined with AlmaLinux 10’s enterprise-grade stability and Red Hat Enterprise Linux compatibility, MySQL creates a robust foundation for mission-critical database operations.
AlmaLinux 10 offers exceptional performance characteristics that make it an ideal choice for MySQL deployments. The operating system provides long-term support, security updates, and seamless compatibility with existing RHEL-based infrastructure. This comprehensive guide walks you through multiple installation methods, security configuration, and optimization techniques to ensure your MySQL database server operates at peak performance.
Whether you’re a system administrator managing production servers, a developer setting up development environments, or a database professional implementing new solutions, this tutorial provides the expertise needed for successful MySQL deployment. You’ll learn industry best practices, troubleshooting techniques, and security hardening procedures that protect your data while maximizing database performance.
Prerequisites and System Requirements
Hardware Requirements
Before installing MySQL on AlmaLinux 10, ensure your system meets the minimum hardware specifications. MySQL requires at least 2GB of RAM for basic operations, though 4GB or more is recommended for production environments. Storage requirements vary based on expected database size, but allocate at least 20GB of available disk space for the MySQL installation and initial databases.
CPU requirements are modest for basic installations, with any modern multi-core processor providing adequate performance. However, database-intensive applications benefit significantly from higher core counts and faster processing speeds.
Software Prerequisites
Your AlmaLinux 10 system must be properly configured with updated packages and enabled repositories. Ensure the AppStream repository is active, as it contains essential MySQL packages. The system should have internet connectivity for downloading packages and dependencies during installation.
Verify that no conflicting database systems are currently installed. MariaDB, PostgreSQL, or previous MySQL versions can create conflicts during installation and should be properly removed before proceeding.
User Permissions and Access Requirements
Root access or sudo privileges are mandatory for MySQL installation and configuration. Database installation requires system-level changes, service management, and firewall configuration that only privileged users can perform.
Network access considerations include opening port 3306 for MySQL communications if remote connections are required. Plan your network security strategy before installation to ensure proper access controls.
Preparation Steps
System Updates and Package Management
Begin by updating your AlmaLinux 10 system to ensure all packages are current and security patches are applied. Execute the following command to update system packages:
sudo dnf update -y
This command downloads and installs all available updates, including security patches and dependency updates that may affect MySQL installation. The process typically takes several minutes depending on the number of available updates.
Repository Configuration
Verify that the AppStream repository is enabled and properly configured. AppStream contains the MySQL packages needed for installation through the default package manager:
sudo dnf repolist enabled
Look for the AppStream repository in the output. If not present, enable it using:
sudo dnf config-manager --enable appstream
Removing Existing MySQL Installations
Check for existing MySQL installations that might conflict with your new setup. Search for currently installed MySQL packages:
rpm -qa | grep -i mysql
If existing installations are found, remove them completely before proceeding:
sudo dnf remove mysql* mariadb*
Back up any existing databases before removal to prevent data loss. Create database dumps using mysqldump or copy data directories to secure locations.
Installation Methods Overview
AlmaLinux 10 provides two primary methods for MySQL installation, each with distinct advantages and use cases. The DNF package manager method utilizes AlmaLinux’s default repositories, ensuring optimal integration with the operating system and simplified dependency management.
The MySQL official repository method provides access to the latest MySQL versions and more granular control over installation options. This approach is preferred when specific MySQL versions are required or when using cutting-edge features not available in default repositories.
Choose the DNF method for standard deployments requiring proven stability and seamless OS integration. Select the official repository method when advanced features, specific versions, or enhanced performance optimizations are priorities.
Method 1: Installing MySQL via DNF Package Manager
Verifying Repository Availability
Confirm that MySQL packages are available in the AppStream repository by searching for available versions:
dnf search mysql-server
This command displays available MySQL server packages and their descriptions. The output should show mysql-server packages ready for installation.
Check package information to understand version details and dependencies:
dnf info mysql-server
Installing MySQL Server Package
Install the MySQL server package using DNF with automatic dependency resolution:
sudo dnf install mysql-server -y
The installation process downloads the MySQL server package along with required dependencies including client libraries, configuration files, and system integration components. DNF automatically handles dependency resolution, ensuring all required packages are installed correctly.
Monitor the installation progress and note any configuration prompts that may appear. The process typically completes within 2-3 minutes depending on network speed and system performance.
Installing MySQL Client Tools
While the server package includes basic client functionality, install additional client tools for enhanced database management capabilities:
sudo dnf install mysql -y
These tools provide command-line database access, import/export utilities, and administrative functions essential for database management and maintenance operations.
Verification of Installation
Confirm successful installation by checking the MySQL version and installation status:
mysql --version
Verify that MySQL server files are properly installed:
rpm -ql mysql-server | head -20
This command lists installed files, confirming successful package installation and proper file placement within the system directory structure.
Method 2: Installing from MySQL Official Repository
Downloading MySQL Repository Setup
Download the MySQL repository configuration package from the official MySQL website:
wget https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm
This package contains repository configuration files that enable access to official MySQL packages. The el9 designation indicates compatibility with RHEL 9-based systems including AlmaLinux 10.
Configuring MySQL Repository
Install the repository configuration package:
sudo dnf install mysql80-community-release-el9-1.noarch.rpm -y
Import the MySQL GPG key for package verification:
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
Verify repository configuration:
dnf repolist enabled | grep mysql
Installing MySQL Community Server
Install MySQL Community Server from the official repository:
sudo dnf install mysql-community-server -y
This installation method provides access to the latest MySQL features and optimizations directly from MySQL developers. The process includes additional configuration options and enhanced performance tuning capabilities.
Package Verification and Dependencies
Confirm package authenticity by verifying GPG signatures:
rpm -qa gpg-pubkey* | grep mysql
Check installed packages and their dependencies:
rpm -qa | grep mysql-community
Starting and Enabling MySQL Service
Starting MySQL Service
Initialize and start the MySQL service using systemctl:
sudo systemctl start mysqld
The initial startup process creates necessary system databases, generates temporary passwords, and configures default settings. This process may take 30-60 seconds during first execution.
Enabling Auto-start on Boot
Configure MySQL to start automatically during system boot:
sudo systemctl enable mysqld
This setting ensures database availability after system restarts, critical for production environments requiring high availability and minimal downtime.
Checking Service Status
Verify MySQL service status and operational state:
sudo systemctl status mysqld
The output displays service status, process information, and recent log entries. Look for “active (running)” status indicating successful service startup.
Service Management Commands
Additional service management commands for MySQL administration:
# Stop MySQL service
sudo systemctl stop mysqld
# Restart MySQL service
sudo systemctl restart mysqld
# Reload MySQL configuration
sudo systemctl reload mysqld
MySQL Security Configuration
Understanding Default Security Settings
AlmaLinux 10 MySQL installations include default security configurations that require immediate attention. The initial setup creates a temporary root password stored in the MySQL error log file.
Locate the temporary root password:
sudo grep 'temporary password' /var/log/mysqld.log
This password is randomly generated and must be changed during the initial security setup process.
Running mysql_secure_installation Script
Execute the MySQL security script to configure essential security settings:
sudo mysql_secure_installation
This interactive script guides you through critical security configurations including root password setup, anonymous user removal, and test database deletion.
Configuring Root Password
When prompted, enter the temporary password found in the log file, then create a strong new root password. MySQL enforces password complexity requirements including:
- Minimum 8 characters length
- Mixed case letters (uppercase and lowercase)
- Numeric digits
- Special characters
Example of a strong password: MySecure123!Pass
Security Best Practices Implementation
The security script presents several configuration options:
- Remove anonymous users: Select “Y” to eliminate anonymous access that could compromise database security.
- Disallow root login remotely: Choose “Y” to restrict root access to local connections only, reducing attack surface area.
- Remove test database: Select “Y” to delete the default test database that provides unnecessary access points.
- Reload privilege tables: Confirm “Y” to activate all security changes immediately.
Additional security measures include configuring firewall rules and implementing user-specific access controls based on the principle of least privilege.
Initial Database Setup and Configuration
Connecting to MySQL Server
Connect to MySQL using the newly configured root password:
mysql -u root -p
Enter your root password when prompted. Successful connection displays the MySQL command prompt (mysql>), indicating ready access to database management functions.
Creating Your First Database
Create a new database for your applications:
CREATE DATABASE myapplication;
Verify database creation:
SHOW DATABASES;
This command displays all available databases including your newly created database alongside system databases.
Setting Up Database Users
Create dedicated user accounts for application access rather than using the root account for regular operations:
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'SecurePassword123!';
Create users for specific IP addresses or networks as needed:
CREATE USER 'appuser'@'192.168.1.%' IDENTIFIED BY 'SecurePassword123!';
Configuring User Permissions
Grant appropriate privileges to user accounts based on application requirements:
GRANT SELECT, INSERT, UPDATE, DELETE ON myapplication.* TO 'appuser'@'localhost';
For administrative users requiring broader access:
GRANT ALL PRIVILEGES ON myapplication.* TO 'admin'@'localhost';
Apply privilege changes:
FLUSH PRIVILEGES;
Test user connectivity by connecting with the new account credentials to verify proper access controls.
Firewall Configuration and Network Access
Configuring Firewalld for MySQL
AlmaLinux 10 uses firewalld for network security management. Open MySQL port 3306 for database connections:
sudo firewall-cmd --permanent --add-service=mysql
Alternatively, open the specific port:
sudo firewall-cmd --permanent --add-port=3306/tcp
Reload firewall configuration:
sudo firewall-cmd --reload
Network Security Considerations
Implement network-level security controls to protect database access. Configure specific IP address ranges for database access:
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="mysql" accept'
This rule restricts MySQL access to devices within the specified network range, enhancing security through network segmentation.
Remote Access Setup
Configure MySQL for remote connections by editing the configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Modify the bind-address setting:
bind-address = 0.0.0.0
Restart MySQL service to apply changes:
sudo systemctl restart mysqld
Test remote connectivity from client systems to ensure proper configuration.
Troubleshooting Common Issues
Installation Problems and Solutions
Package conflicts may occur during installation. Resolve dependency issues by cleaning package cache:
sudo dnf clean all
sudo dnf makecache
Repository configuration problems can be resolved by refreshing repository metadata:
sudo dnf repolist --refresh
Service Startup Issues
MySQL service startup failures often result from configuration errors or insufficient system resources. Check system logs for error details:
sudo journalctl -u mysqld -f
Common startup issues include:
- Insufficient disk space in /var/lib/mysql
- Permission problems with MySQL data directory
- Configuration file syntax errors
- Port conflicts with other services
Connection and Authentication Problems
Authentication failures typically stem from incorrect passwords or user configuration issues. Reset root password if necessary:
sudo systemctl stop mysqld
sudo mysqld_safe --skip-grant-tables &
Connect without password and reset credentials:
UPDATE mysql.user SET authentication_string=PASSWORD('NewPassword123!') WHERE User='root';
FLUSH PRIVILEGES;
Performance Optimization Tips
Monitor MySQL performance using built-in tools:
SHOW PROCESSLIST;
SHOW ENGINE INNODB STATUS;
Optimize configuration parameters in /etc/my.cnf:
[mysqld]
innodb_buffer_pool_size = 1G
max_connections = 200
query_cache_size = 128M
Best Practices and Recommendations
Production Environment Considerations
Production MySQL deployments require additional configuration considerations including automated backups, monitoring systems, and high availability configurations. Implement regular backup schedules using mysqldump or binary backup methods.
Configure log rotation to manage disk space usage effectively. Set up monitoring tools to track database performance metrics and identify potential issues before they impact operations.
Security Hardening Guidelines
Beyond basic security configuration, implement additional hardening measures including SSL/TLS encryption for connections, audit logging for compliance requirements, and regular security updates.
Configure file system permissions to restrict access to MySQL data directories. Implement network security controls including VPNs or private networks for database access.
Performance Optimization
Optimize MySQL performance through proper indexing strategies, query optimization, and configuration tuning. Monitor slow query logs to identify performance bottlenecks and optimization opportunities.
Consider implementing read replicas for high-traffic applications and partitioning strategies for large datasets.
Backup and Maintenance Strategies
Establish comprehensive backup procedures including full backups, incremental backups, and point-in-time recovery capabilities. Test backup restoration procedures regularly to ensure data recovery reliability.
Schedule regular maintenance tasks including index optimization, table analysis, and log file management to maintain optimal database performance.
Congratulations! You have successfully installed MySQL. Thanks for using this tutorial for installing the MySQL database server on your AlmaLinux OS 10 system. For additional help or useful information, we recommend you check the official MySQL website.