升级前准备:
[root@node01 ~]# mysql -V
mysql Ver 14.14 Distrib 5.7.25, for linux-glibc2.12 (x86_64) using EditLine wrapper
# 进入原5.7 mysql命令行 正确关闭数据库
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.25-log |
+------------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_fast_shutdown';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| innodb_fast_shutdown | 1 |
+----------------------+-------+
1 row in set (0.00 sec)
# 确保数据都刷到硬盘上,更改成0
mysql> set global innodb_fast_shutdown=0;
Query OK, 0 rows affected (0.00 sec)
mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
升级步骤:
[root@node01 ~]# tar -xvf mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xz
[root@node01 ~]# ln -s /root/mysql-8.0.22-linux-glibc2.17-x86_64-minimal /usr/local/mysql8
[root@node01 ~]# ll /usr/local/mysql8
lrwxrwxrwx. 1 root root 49 Nov 4 00:13 /usr/local/mysql8 -> /root/mysql-8.0.22-linux-glibc2.17-x86_64-minimal
[root@node01 ~]# chown -R mysql.mysql /usr/local/mysql8*
[root@node01 ~]# vi /etc/profile
export MYSQL_HOME=/usr/local/mysql8
export PATH=$PATH:$MYSQL_HOME/bin
[root@node01 ~]# mysql -V
mysql Ver 8.0.22 for Linux on x86_64 (MySQL Community Server - GPL)
参数文件:
[mysql]
port=3306
socket=/tmp/mysql.sock
[mysqld]
port=3306
socket=/tmp/mysql.sock
user=mysql
server-id=1
basedir=/usr/local/mysql8
datadir=/mysql/3306/data
log-bin=/mysql/3306/binlog/mysql-bin
binlog_format=row
gtid_mode = ON
enforce_gtid_consistency = ON
[root@node01 ~]# /usr/local/mysql8/bin/mysqld_safe &
[1] 9328
[root@node01 ~]# 2020-11-03T16:17:42.786011Z mysqld_safe Logging to '/mysql/3306/data/node01.err'.
2020-11-03T16:17:42.824011Z mysqld_safe Starting mysqld daemon with databases from /mysql/3306/data
[root@node01 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.22 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.22 |
+-----------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test |
+----------------+
1 row in set (0.00 sec)
mysql> select * from test;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
+------+
3 rows in set (0.00 sec)
配置mysqld服务:
[root@node01 ~]# cp /usr/local/mysql8/support-files/mysql.server /etc/init.d/mysqld8