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.
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.
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.rpmInstallation using yum
# yum install -y mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-8.0.43-1.el9.x86_64.rpmStarting MySQL and retrieving the temporary password
# systemctl enable --now mysqld
# grep password /var/log/mysqld.logThe 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
