下载安装
https://dev.mysql.com/downloads/repo/yum/
yum -y install mysql80-community-release-el6-3.noarch.rpm # centos6
yum -y install yum-utils
5.1 -> 5.5
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql55-community
yum update mysql-server
service mysqld restart
mysql_upgrade
service mysqld restart
5.5 -> 5.6
yum-config-manager --disable mysql55-community
yum-config-manager --enable mysql56-community
yum update mysql-server
service mysqld restart
mysql_upgrade
service mysqld restart
5.6 -> 5.7
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community
yum update mysql-server
service mysqld restart
mysql_upgrade
service mysqld restart
mysql 升级使用 mariadb
对应关系
MySQL 5.5 -> MariaDB 5.5
MySQL 5.6 -> MariaDB 10.0
MySQL 5.7 -> MariaDB 10.2
编辑文件
/etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2021-07-07 06:51 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos6-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
mariadb 升级过程
从版本 mysql5.7 开始
mysql5.7 -> mariadb10.2
service mysqld stop
yum-config-manager --disable mysql57-community
yum remove mysql-community-*
yum -y install mysql-server
# or
# yum -y install MariaDB-server
service mysql start
mysql_upgrade
service mysql restart
编辑 /etc/yum.repos.d/MariaDB.repo 修改版本可升级 10.2 > 10.3 > 10.4
mariadb10.2 -> mariadb10.3
# 编辑 /etc/yum.repos.d/MariaDB.repo 文件,修改版本
yum clean all
service mysql stop
yum -y remove mysql-server
# or
# yum -y remove MariaDB-server
yum -y install mysql-server
# or
# yum -y install MariaDB-server
service mysql start
mysql_upgrade
service mysql restart
mariadb10.3 -> mariadb10.4
修改 MariaDB.repo, 重复上述升级过程, 文件版本即可
总结
1 升级必须是逐步递增升级, 不能跨版本升级
2 升级后必须使用升级命令mysql_upgrade
3 升级重启后查看日志文件, 是否有错误提示, 必须修复后才可进行下一步升级