1.下载
https://repo.mysql.com/
找到
wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
2.安装 yum repo文件并更新 yum 缓存
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
yum clean all
yum makecache
yum provides '*/applydeltarpm'
yum -y install deltarpm-3.6-3.el7.x86_64
yum install epel-release
3.使用 yum安装mysql
可以看到 MySQL 5.5 5.6 5.7为禁用状态 而MySQL 8.0为启用状态;
[root@lys-mysql-test001 ~]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 230
mysql-connectors-community-source MySQL Connectors Community disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 138
mysql-tools-community-source MySQL Tools Community - Sou disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Sourc disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server disabled
mysql57-community/x86_64 MySQL 5.7 Community Server disabled
mysql57-community-source MySQL 5.7 Community Server disabled
mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 321
mysql80-community-source MySQL 8.0 Community Server disabled
查看小版本
[root@192-168-125-189 ~]# yum list mysql-community-server --showduplicates | sort -r
* updates: mirrors.ustc.edu.cn
mysql-community-server.x86_64 8.0.29-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.28-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.27-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.26-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.25-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.24-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.23-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.22-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.21-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.20-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.19-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.18-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.17-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.16-2.el7 mysql80-community
mysql-community-server.x86_64 8.0.16-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.15-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.14-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.13-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.12-1.el7 mysql80-community
mysql-community-server.x86_64 8.0.11-1.el7 mysql80-community
安装
[root@lys-mysql-test001 ~]# yum search mysql | grep mysql-community-server.x86_64
mysql-community-server.x86_64 : A very fast and reliable SQL database server
# 导入key,不然出现如下错误
# Failing package is: mysql-community-client-8.0.28-1.el7.x86_64 GPG Keys are configured
# as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
# 安装指定小版本
yum install -y mysql-community-server-8.0.25
4.开启mysql 服务
systemctl enable mysqld.service
systemctl start mysqld.service
5.获取初始密码登录mysql
[root@lys-mysql-test001 ~]# cat /var/log/mysqld.log | grep password
2022-04-14T06:49:57.151045Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ed>1Rfx?
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'AAbb1122!!';
注意位数和种类至少大+写+小写+符号+数字
6.脚本直接安装
#!/usr/bin/env bash
yum install -y wget
wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-server.x86_64
systemctl enable mysqld.service
cat /var/log/mysqld.log | grep password