1、备份数据库
[root@node42 ~]# mysqldump -uroot -h192.168.21.42 -p test > dumptest.sql
2、停止旧版本mysql
[root@node42 log]# /etc/init.d/mysqld stop
3、安装新版本二进制包
[root@node42 ~]# tar -xvf mysql-8.0.25-el7-x86_64.tar.gz
[root@node42 ~]# mv mysql-8.0.25-el7-x86_64 /usr/local/mysql
[root@node42 ~]# cd /usr/local/mysql
[root@node42 mysql]# ll
total 344
drwxr-xr-x 2 mysql mysql 4096 Sep 6 15:07 bin
drwxr-xr-x 6 mysql mysql 4096 Sep 6 16:02 data
drwxr-xr-x 2 mysql mysql 4096 Sep 6 15:08 docs
drwxr-xr-x 2 mysql mysql 4096 Sep 6 15:13 etc
drwxr-xr-x 3 mysql mysql 4096 Sep 6 15:07 include
drwxr-xr-x 5 mysql mysql 4096 Sep 6 15:08 lib
-rw-r--r-- 1 mysql mysql 301518 Apr 8 2018 LICENSE
drwxr-xr-x 2 mysql mysql 4096 Sep 6 15:15 log
drwxr-xr-x 4 mysql mysql 4096 Sep 6 15:07 man
drwxr-xr-x 9 root root 4096 Sep 6 16:13 mysql-8.0.25-el7-x86_64
-rw-r--r-- 1 mysql mysql 687 Apr 8 2018 README
drwxr-xr-x 28 mysql mysql 4096 Sep 6 15:08 share
drwxr-xr-x 2 mysql mysql 4096 Sep 6 15:08 support-files
[root@node42 mysql]# mv mysql-8.0.25-el7-x86_64 mysql
4、启动新版本mysql,自动完成升级
[root@node42 log]# /etc/init.d/mysqld start
Starting MySQL.............................................[ OK ]...........................................................
[root@node42 bin]# tailf /usr/local/mysql/log/error.log
2021-09-06T16:56:56.829135+08:00 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.25) starting as process 12377
2021-09-06T16:56:56.852108+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-09-06T16:56:57.888900+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-09-06T16:56:57.920689+08:00 1 [System] [MY-011090] [Server] Data dictionary upgrading from version '80011' to '80023'.
2021-09-06T16:57:01.823771+08:00 1 [System] [MY-013413] [Server] Data dictionary upgrade from version '80011' to '80023' completed.
2021-09-06T16:57:03.340807+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /usr/local/mysql/data/mysqlx.sock
2021-09-06T16:57:19.706012+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80011' to '80025' started.
2021-09-06T16:58:46.840219+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80011' to '80025' completed.
2021-09-06T16:58:48.167769+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-09-06T16:58:48.168683+08:00 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-09-06T16:58:48.315535+08:00 0 [System] [MY-010931] [Server] /usr/local/mysql/bin/mysqld: ready for connections. Version: '8.0.25' socket: '/usr/local/mysql/data/mysql.sock' port: 3306 MySQL Community Server - GPL.
5、查看MySQL版本
[root@node42 log]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.25 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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> \s
--------------
mysql Ver 8.0.25 for Linux on x86_64 (MySQL Community Server - GPL)
Connection id: 10
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.25 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /usr/local/mysql/data/mysql.sock
Binary data as: Hexadecimal
Uptime: 6 min 54 sec
Threads: 2 Questions: 11 Slow queries: 0 Opens: 647 Flush tables: 6 Open tables: 37 Queries per second avg: 0.026
--------------