Centos7 mysql5.6升级mysql5.7

HUC-WFX 1年前 ⋅ 13928 阅读

操作系统:centos7

一、前言 系统架构升级导致接口不能启动

二 、升级步骤

1.下载并安装MySQL官方的 Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

在该文件路径执行yum安装命令

yum -y install mysql57-community-release-el7-10.noarch.rpm

2.设置源中的5.7为有效

通过以下命令可以查看安装源所支持的所有版本

yum repolist all | grep mysql

默认是 mysql80-community 有效,使 5.7 有效的方法是执行下面两条命令:

yum-config-manager --disable mysql80-community

yum-config-manager --enable mysql57-community

执行后再查看repo

yum repolist all | grep mysql
Repository epel is listed more than once in the configuration

mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community 禁用

mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用

!mysql-connectors-community/x86_64 MySQL Connectors Community 启用: 131

mysql-connectors-community-source MySQL Connectors Community - Sou 禁用

!mysql-tools-community/x86_64 MySQL Tools Community 启用: 100

mysql-tools-community-source MySQL Tools Community - Source 禁用

mysql-tools-preview/x86_64 MySQL Tools Preview 禁用

mysql-tools-preview-source MySQL Tools Preview - Source 禁用

mysql55-community/x86_64 MySQL 5.5 Community Server 禁用

mysql55-community-source MySQL 5.5 Community Server - Sou 禁用

!mysql56-community/x86_64 MySQL 5.6 Community Server 禁用

mysql56-community-source MySQL 5.6 Community Server - Sou 禁用

!mysql57-community/x86_64 MySQL 5.7 Community Server 启用: 384

mysql57-community-source MySQL 5.7 Community Server - Sou 禁用

mysql80-community/x86_64 MySQL 8.0 Community Server 禁用

mysql80-community-source MySQL 8.0 Community Server - Sou 禁用

3.备份mysql数据库(该步骤可选)

备份所有数据库

mysqldump -u -p -all-databases > /path/to/file/mysqlback.bak

也可备份指定数据库

mysqldump -u -p 数据库名 > /path/to/file/XXX.bak



mysql -u -p 数据库名 < /root/XXX.bak

4.停止mysql服务

systemctl stop mysqld

5.升级mysql

yum update mysql-server

6.更新数据库权限

systemctl start mysql
mysql_upgrade -u root -p --force