1.准备软件包和解压
mysql-8.0.24-linux-glibc2.12-x86_64.tar.xz
mysql-shell-8.0.20-linux-glibc2.12-x86-64bit.tar.gz
tar -xf mysql-8.0.24-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
cd /usr/local/
ln -s mysql-8.0.24-linux-glibc2.12-x86_64/ mysql8.0
mkdir data -p
chown mysql.mysql /usr/local/mysql8.0/
chown mysql.mysql /usr/local/mysql8.0/* -R
2.升级前预检测(mysql-shell 必须要对应版本)
tar -xf mysql-shell-8.0.20-linux-glibc2.12-x86-64bit.tar.gz -C /usr/local/
cd /usr/local/
ln -s mysql-shell-8.0.20-linux-glibc2.12-x86-64bit/ mysqlshell
vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysqlshell/bin:$PATH
source !$
mysqlsh --version
3.原先数据进行对mysql-shell进行授权(mysql5.7)
mysql> create user shell@"%" identified by "123";
mysql> grant all on *.* to shell@'%';
4.升级前准备
[root@localhost bin]# mysqlsh shell:123@192.168.137.103:3306 -e 'util.checkForServerUpgrade()' >>/tmp/up.log #检测下
[root@localhost bin]# cat /tmp/up.log (有error要必须解决)
5.优雅的关闭5.7数据库
mysql> set global innodb_fast_shutdown=0;
mysql> select @@innodb_fast_shutdown;
mysql> shutdown;
6.备份原先数据库的my.cnf
[root@localhost bin]# cp /etc/my.cnf my.cnf.bak
7.修改my.cnf(修改成成8.0的)
[root@localhost mysql8]# vim /usr/local/mysql8/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql8.0/
datadir=/usr/local/mysql/data #注意这里是写原数据(5.7的)
port=3307
socket=/tmp/mysql.sock
log_error=/usr/local/mysql8.0/err.log #这里要创建文件
8.启动数据
[root@localhost mysql8]# /usr/local/mysql8/bin/mysqld_safe --defaults-file=/usr/local/mysql8/my.cnf --skip-grant-tables --skip-networking &
9.测试是否已经成功升级了
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.20 |
+-----------+
1 row in set (0.00 sec)