点击以下链接可以自动跳转:MySQL官网
接下来按如图所示依次点击进入。
选择自己所需要版本
此处如需下载历史版本可以点击
1、登录ssh或其他相关软件上传mysql安装包
2、查看并解压刚刚上传的文件
解压命令如下:
tar -xvf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
3、查询是否有mariadb,如果有将其强制卸载掉
解压命令如下:
#查询命令
rpm -qa|grep mariadb
#强制卸载命令
rpm -e --nodeps maraidb-libs
卸载后检查是否卸载干净
4、依此安装所需mysql
依次执行如下指令(各包之有依赖关系,所以要依次执行)
rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
最后一步可能会出错如果出错可以在最后加 --force --nodeps如下:
rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm --force --nodeps
具体步骤如下:
[root@localhost mysql]# ls
mysql-community-client-8.0.28-1.el7.x86_64.rpm mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm mysql-community-libs-8.0.28-1.el7.x86_64.rpm
mysql-community-common-8.0.28-1.el7.x86_64.rpm mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm
mysql-community-devel-8.0.28-1.el7.x86_64.rpm mysql-community-server-8.0.28-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.28-1.el7.x86_64.rpm mysql-community-test-8.0.28-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm
警告:mysql-community-common-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-common-8.0.28-1.e################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
警告:mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-client-plugins-8.################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
警告:mysql-community-libs-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-8.0.28-1.el7################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
警告:mysql-community-client-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-client-8.0.28-1.e################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
警告:mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-icu-data-files-8.################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
错误:依赖检测失败:
/usr/bin/perl 被 mysql-community-server-8.0.28-1.el7.x86_64 需要
net-tools 被 mysql-community-server-8.0.28-1.el7.x86_64 需要
perl(Getopt::Long) 被 mysql-community-server-8.0.28-1.el7.x86_64 需要
perl(strict) 被 mysql-community-server-8.0.28-1.el7.x86_64 需要
[root@localhost mysql]# rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm --force --nodeps
警告:mysql-community-server-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-8.0.28-1.e################################# [100%]
[root@localhost mysql]#
5、初始化
mysqld --initialize --console
6、修改安装目录的所有者和所属组,以便让mysql软件用户有权限直接使用
chown -R mysql.mysql /var/lib/mysql/
7、启动mysql并修改密码