November 7, 2025

MySQL 8.4.6 Single-Node Installation Guide on Linux

This guide provides step-by-step instructions for installing MySQL 8.4.6 on Linux using RPM packages, covering initial setup, configuration, and troubleshooting common issues.

This article details the process of installing MySQL 8.4.6 on a Linux platform using RPM packages, including initial configuration, and addresses common problems encountered during installation along with their solutions.

Before installation, check if MySQL is pre-installed on the system:

rpm -qa | grep mysql

If MySQL is installed, you can remove it:

rpm -e mysql    # Standard removal mode
rpm -e --nodeps mysql    # Forceful removal mode, use if dependencies prevent removal

Next, we will install MySQL on a CentOS 7 system using the yumcommand. Note that MySQL has been removed from the default program list in CentOS 7. Therefore, we first need to download the Yum repository package from the official website: https://dev.mysql.com/downloads/repo/yum/

Alternatively, you can use this pre-downloaded file from a cloud drive:

File: mysql84-community-release-el7-2.noarch.rpm

Link: https://pan.baidu.com/s/155dmkIqsnbj8kXdamFpkKA?pwd=sdkc

After downloading, upload the .rpmpackage to your CentOS 7 virtual machine using a tool like sftp, scp, or a shared folder. Then, in the VM, navigate to the directory containing the .rpmpackage and install it using the rpm -ivhcommand. Subsequently, run yum updateand yum install mysql-serverto install the MySQL server.

Alternatively, if the VM has internet access, use the wgetcommand to download the MySQL Yum repository package directly inside the VM.

wget http://repo.mysql.com/mysql-community-release-el7-2.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server

Set permissions:

chown -R mysql:mysql /var/lib/mysql/

Initialize MySQL:

mysqld --initialize

Start MySQL:

systemctl start mysqld

Check MySQL status:

systemctl status mysqld

Note:​​ When starting the MySQL service for the first time, the MySQL server performs initial configuration. MySQL 8.0+ generates a temporary password for the rootuser upon first startup and logs it. You need to find it to proceed.

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

After execution, copy the temporary password following the colon.

Run the security configuration script, which guides you through changing the password, removing anonymous users, etc.

mysql_secure_installation

After execution, a series of prompts will appear. You can respond as follows:

  • Enter password for user root:Paste the temporary password you just copied and press Enter.
  • New password:Enter your new password (Note: The password must include uppercase letters, lowercase letters, numbers, and special characters; otherwise, it might fail security checks).
  • Re-enter new password:Re-enter the new password.
  • For the subsequent prompts (e.g., Remove anonymous users?, Disallow root login remotely?), simply press yand Enter for the recommended security settings.

Log in to MySQL using the new password to verify success.

mysql -u root -p

When prompted Enter password:, enter the new password you just set and press Enter. If you successfully enter the mysql>command line, you have fully succeeded!

⚠️⚠️⚠️⚠️⚠️⚠️ ​Ensure you download the version corresponding to your system.​​ For example, if you are using CentOS 7, download the Linux 7 version. Otherwise, you may encounter errors like the one below:

This error indicates that the package mysql84-community-release-el10-2.noarch.rpmdepends on a specific version of rpm-lib(PayloadIsZstd)(<= 5.4.18-1), but the version installed on the current system does not meet this requirement, causing the installation to fail.

⚠️⚠️⚠️⚠️⚠️⚠️ If you are using a brand-new virtual machine or a fresh Linux environment, yum updatemight fail primarily because Yum cannot resolve the hostname mirrorlist.centos.org, preventing it from fetching the mirror list and ultimately causing the operation to fail.

Address this issue from two aspects:

  1. DNS Configuration Issue:​​ The system's DNS server settings are incorrect, preventing the resolution of the domain name mirrorlist.centos.org.
  2. Network Connection Problem:​​ The virtual machine might have network connectivity issues, unable to communicate with external networks (including DNS servers and CentOS mirrors).

Edit the /etc/resolv.conffile (using vior nano), and add the following content (using Google's public DNS as an example):

nameserver 8.8.8.8
nameserver 8.8.4.4

Save the file and try running the yum updatecommand again to see if domain name resolution works.

Check the virtual machine's network adapter settings to ensure the connection mode (e.g., NAT, Bridged) is correct and that the VM can ping external addresses (e.g., ping www.baidu.com). If it cannot ping, check if the network service is running properly. Execute systemctl status networkto check the network service status. If it's not running, execute systemctl start networkto start it.

⚠️⚠️⚠️⚠️⚠️⚠️ If the issue persists and you see a problem as shown in the figure (not provided), it might be because CentOS 7 has reached End-of-Life (EOL), and the official repositories may no longer be available, causing yumto fail to fetch update information.

The solution is to switch to a third-party repository. Here's an example using Alibaba Cloud's CentOS 7 repository:

Back up the original CentOS-Base.repofile:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

Download Alibaba Cloud's CentOS 7 repository configuration file:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

If wgetis not installed, install it first by executing yum install -y wget.

Clear the Yum cache and regenerate it:

yum clean all
yum makecache

Execute yum updateagain.

Additionally, firewall rules might be blocking yumfrom communicating with external repositories.

systemctl stop firewalld
systemctl disable firewalld

After stopping the firewall, try yum update. If it works normally, the issue was related to firewall rules.

⚠️⚠️⚠️⚠️⚠️⚠️ When trying to install wget, you might encounter a situation where the wgetpackage cannot be found in the Yum repositories, and subsequent wgetcommands fail because it's not installed.

The reason is that the Yum repository does not contain the wgetpackage. Furthermore, when executing the wgetcommand later, it fails because wgetis not installed (command not found).

The solution is to configure the system's base Yum repository (like the official CentOS repository or a third-party one like Alibaba Cloud's) to obtain system tool packages like wget.

Since wgetis not installed yet and cannot be used directly to download, obtain the repository configuration file via these methods:

Method 1: Download from another machine and transfer

On a machine with internet access, visit https://mirrors.aliyun.com/repo/Centos-7.repo, save the page content as a CentOS-Base.repofile, then transfer this file to the target machine's /etc/yum.repos.d/directory using scp, sftp, etc.

Method 2: Download on the target machine using curl(if installed)​

If curlis installed on the system, execute the following command:

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

After configuring the repository, execute the following commands to clear the existing Yum cache and generate a new one, making the new repository configuration effective:

yum clean all
yum makecache

Now that the Yum repository is correctly configured, proceed with the installation of wget.

⚠️⚠️⚠️⚠️⚠️⚠️ You might encounter the following error when starting MySQL: Failed to start mysqld.service: Unit not found.

This indicates that the system cannot find the mysqld.serviceservice unit file.

First, use the command yum list installed | grep mysqlto view the list of installed MySQL-related packages. Ensure that mysql-serverand other necessary dependency packages are installed successfully.

The error typically means the mysqld.serviceservice unit file is missing, which suggests the MySQL server package (mysql-community-server) was not installed correctly.

Here is the solution:

Install the MySQL server package, which provides the mysqld.servicefile:

yum install -y mysql-community-server

Start the MySQL service after installation:

systemctl start mysqld

Check the MySQL service status:

systemctl status mysqld

If the output shows active (running), the MySQL service has started successfully.

You will get best features of ChatDBA