AlmaLinux

Install MySQL 8.4 LTS on Rocky Linux 10 / AlmaLinux 10

MySQL is the most widely used open source relational database management system. It powers web applications, enterprise systems, and data-driven workloads across industries. MySQL 8.4 is the current Long-Term Support (LTS) release, offering stability and extended support from Oracle.

Original content from computingforgeeks.com - post 69022

This guide covers installing MySQL 8.4 LTS on Rocky Linux 10 and AlmaLinux 10 using the official MySQL community repository, securing the installation, and configuring remote access with firewall rules.

Prerequisites

  • A server running Rocky Linux 10 or AlmaLinux 10
  • Root or sudo access
  • Internet connectivity
  • Port 3306/tcp open if remote clients need access

Step 1: Update System Packages

Update your system to the latest packages before proceeding.

sudo dnf -y update

Reboot if kernel updates were applied.

sudo reboot

Step 2: Add MySQL 8.4 Repository

Rocky Linux and AlmaLinux ship with MariaDB by default. To install MySQL, add the official MySQL community repository from Oracle.

sudo dnf install -y https://dev.mysql.com/get/mysql84-community-release-el10-2.noarch.rpm

Verify the repository is enabled.

sudo dnf repolist | grep mysql

You should see mysql-8.4-lts-community and mysql-tools-8.4-lts-community listed.

Step 3: Install MySQL 8.4 on Rocky Linux 10 / AlmaLinux 10

If MariaDB packages are installed, remove them first to avoid conflicts.

sudo dnf remove -y mariadb-server mariadb 2>/dev/null
sudo dnf module disable -y mariadb 2>/dev/null

Install MySQL server and client packages.

sudo dnf install -y mysql-community-server mysql-community-client

Verify the installed version.

$ mysql --version
mysql  Ver 8.4.8 for Linux on x86_64 (MySQL Community Server - GPL)

Step 4: Start and Enable MySQL Service

Enable MySQL to start on boot and start it now.

sudo systemctl enable --now mysqld

Verify the service is running.

$ systemctl status mysqld
● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
     Active: active (running)

Step 5: Secure MySQL Installation

MySQL generates a temporary root password during initial startup. Retrieve it from the log file.

sudo grep 'temporary password' /var/log/mysqld.log

Run the security script to set a new root password and remove test databases and anonymous users.

sudo mysql_secure_installation

The script prompts for the following:

  • Enter the temporary root password from the log
  • Set a new root password (must meet the default policy: 8+ chars, uppercase, lowercase, number, special character)
  • Remove anonymous users – Yes
  • Disallow root login remotely – Yes
  • Remove test database – Yes
  • Reload privilege tables – Yes

Step 6: Test MySQL Access

Log in to the MySQL shell with the new root password.

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.4.8 MySQL Community Server - GPL

mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.4.8     |
+-----------+
1 row in set (0.00 sec)

Step 7: Create a Database and User

Create a database and a dedicated user with full privileges on it. This is standard practice – never use the root account for application connections.

mysql> CREATE DATABASE appdb;
mysql> CREATE USER 'appuser'@'%' IDENTIFIED BY 'StrongPass@2026';
mysql> GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'%';
mysql> FLUSH PRIVILEGES;

The '%' host allows connections from any IP. For better security, replace with a specific IP or subnet like '10.0.1.%'.

Step 8: Configure Firewall

If remote clients need to connect to MySQL, open port 3306/tcp in firewalld.

sudo firewall-cmd --permanent --add-port=3306/tcp
sudo firewall-cmd --reload

Verify the port is open.

sudo firewall-cmd --list-ports

Step 9: Enable Remote Access (Optional)

By default, MySQL binds to localhost only. To allow remote connections, edit the MySQL configuration.

sudo vi /etc/my.cnf.d/mysql-server.cnf

Add or update the bind-address under the [mysqld] section:

[mysqld]
bind-address = 0.0.0.0

Restart MySQL to apply the change.

sudo systemctl restart mysqld

Test remote access from another machine.

mysql -h 10.0.1.50 -u appuser -p appdb

Useful MySQL Commands

CommandDescription
SHOW DATABASES;List all databases
SHOW TABLES;List tables in current database
SHOW GRANTS FOR 'user'@'host';Check user privileges
mysqldump -u root -p dbname > backup.sqlBackup a database
mysql -u root -p dbname < backup.sqlRestore a database
SELECT @@datadir;Show data directory location

Conclusion

MySQL 8.4 LTS is installed and running on Rocky Linux 10 / AlmaLinux 10. For production deployments, enable TLS/SSL encryption for client connections, set up automated backups with mysqldump or Percona XtraBackup, and configure Prometheus monitoring to track query performance and resource usage.

Related Articles

Databases How To Install MariaDB 10.6 on Amazon Linux 2 Databases Monitor Percona MySQL / Percona XtraDB With Prometheus and Grafana CentOS Install Centreon Monitoring Tool on CentOS 8 | Rocky Linux 8 Databases How To Configure MongoDB Replication on Ubuntu

Leave a Comment

Press ESC to close