Databases 39 min read

Step-by-Step Guide: Installing MySQL via RPM on Rocky, AlmaLinux, CentOS and More

This article provides a comprehensive, cross‑platform tutorial for downloading MySQL RPM bundles, installing required dependencies, using rpm or yum to install MySQL on various RHEL‑compatible distributions, starting the service, retrieving the temporary root password, and securely changing it to a permanent one.

Raymond Ops
Raymond Ops
Raymond Ops
Step-by-Step Guide: Installing MySQL via RPM on Rocky, AlmaLinux, CentOS and More

Downloading MySQL RPM packages

Visit the official MySQL website, select the desired version (e.g., 8.0.43 or 8.4.6), choose the operating system "Red Hat Enterprise Linux / Oracle Linux" with the appropriate OS version, and click the "RPM Bundle" download button.

Download MySQL RPM package
Download MySQL RPM package

Preparing the system

Install missing utilities (wget, tar) and required dependencies (perl, net‑tools, libaio) with yum install -y wget tar perl net-tools libaio before proceeding.

Installation using rpm

# rpm --import https://mirrors.nju.edu.cn/mysql/RPM-GPG-KEY-mysql-2023
# rpm -ivh mysql-community-client-plugins-8.0.43-1.el9.x86_64.rpm
# rpm -ivh mysql-community-common-8.0.43-1.el9.x86_64.rpm
# rpm -ivh mysql-community-libs-8.0.43-1.el9.x86_64.rpm
# rpm -ivh mysql-community-client-8.0.43-1.el9.x86_64.rpm
# rpm -ivh mysql-community-icu-data-files-8.0.43-1.el9.x86_64.rpm
# rpm -ivh mysql-community-server-8.0.43-1.el9.x86_64.rpm

Installation using yum

# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.0.43-1.el9.x86_64.rpm

Starting MySQL and retrieving the temporary password

# systemctl enable --now mysqld
# grep password /var/log/mysqld.log

The log entry contains a line such as "A temporary password is generated for root@localhost: temporary_password ". Use this password to log in.

Changing the root password

# mysqladmin -uroot -p'temporary_password' password NewStrongPassword123!
# mysql -uroot -p'NewStrongPassword123!'

Ensure the new password satisfies MySQL's password policy (minimum length, mixed character types).

Verification

# mysql -V
# mysql -uroot -p'NewStrongPassword123!' -e "SHOW DATABASES;"

The output should list the default schemas (information_schema, mysql, performance_schema, sys), confirming a successful installation. The same sequence—download, install dependencies, run rpm or yum, start the service, retrieve and change the password—applies to Rocky 8, AlmaLinux 8, CentOS 7, Rocky 10, and other listed distributions, with only the OS version string in the download URL differing accordingly.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databaseLinuxmysqlRPMyumRPM installation
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.