Add the official MySQL Yum repository and install the server package.
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
yum install -y mysql-community-server
Verify the service was created.
systemctl status mysql
Initial Service Configuration and Root Access
After installation, start the service and configure it to launch on boot.
systemctl start mysqld.service
systemctl enable mysqld.service
systemctl status mysqld.service
The initial root password is logged. Retrieve it and log into MySQL.
grep 'temporary password' /var/log/mysqld.log
mysql -u root -p
Upon first login, you must change the password to comply with MySQL 8.0's security policy.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewStrongPassword!123';
Creating a Database User with Remote Access
Create a dedicated user for applications and grant privileges.
CREATE USER 'app_user'@'%' IDENTIFIED BY 'AppUserPassword123!';
GRANT ALL PRIVILEGES ON *.* TO 'app_user'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Adjusting Authentication Plugin for Legacy Clients
Older database clients may not support MySQL 8.0's default caching_sha2_password plugin. To allow connections from tools like older Navicat versions, change the authentication method.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourNewStrongPassword!123';
To apply this change to a remote user, replace 'localhost' with '%'.
ALTER USER 'app_user'@'%' IDENTIFIED WITH mysql_native_password BY 'AppUserPassword123!';
Recovering from a Failed Installation Attempt
If a previous MySQL installation was incomplete or corrupted, clean up the system before a fresh install.
systemctl stop mysqld
rpm -qa | grep -i mysql | xargs rpm -e --nodeps
rm -rf /var/lib/mysql
rm -f /etc/my.cnf
rm -f /usr/lib/systemd/system/mysqld.service
Troubleshooting Missing Dependencies
If the installer reports missing shared libraries (libcrypto.so.10, libssl.so.10), the issue is often an incorrect repository URL for your OS version. Ensure you are using the correct el8 or el7 repository package.
For RHEL 8 or Rocky Linux 8:
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el8-4.noarch.rpm
Resolving RPM-GPG Key Errors
If package installation fails due to GPG key verification errors, import the current MySQL public key.
yum clean packages
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
yum install -y mysql-community-server
Configuring Binary Log Rotation and Disk Space
Improper binlog settings can lead to disk exhaustion. A large max_binlog_size combined with an active backup process that locks log rotation can prevent old files from being purged. Reduce the maximum log file size to ensure more frequent rotation and cleanup.
Edit the main configuration file.
vim /etc/my.cnf
Add or modify these directives under the [mysqld] section.
# Enables binary logging
log_bin = /var/log/mysql/mysql-bin.log
# Sets expiration time for logs (e.g., 7 days)
binlog_expire_logs_seconds = 604800
# Sets a conservative maximum size for each binary log file
max_binlog_size = 20M