一、从官网下载离线安装包
https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.30-1.el7.x86_64.rpm-bundle.tar
二、上传到Linux服务器并解压
tar -xvf mysql-8.0.30-1.el7.x86_64.rpm-bundle.tar
三、安装MySQL
rpm -ivh ./mysql-community-client-plugins-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-common-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-debuginfo-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-devel-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-embedded-compat-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-icu-data-files-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-libs-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-libs-compat-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-server-8.0.30-1.el7.x86_64.rpm --force --nodeps
rpm -ivh ./mysql-community-server-debug-8.0.30-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-client-8.0.30-1.el7.x86_64.rpm
安装可能出现如下问题。
执行“yum remove mysql-libs”后重试即可
四、启动服务
#启动服务
systemctl start mysqld
#设置为开机自动启动
systemctl enable mysqld
五、获取root用户初始密码
cat /var/log/mysqld.log