1、升级前准备
1.1.mysql-shell验证
下载shell验证文件:
https://downloads.mysql.com/archives/shell/
复制
解压验证:
[root@mysql mysql]# tar -zxvf mysql-shell-8.0.26-linux-glibc2.12-x86-64bit.tar.gz [root@mysql mysql]# cd mysql-shell-8.0.26-linux-glibc2.12-x86-64bit/bin [root@mysql bin]# ./mysqlsh MySQL Shell 8.0.26 Copyright (c) 2016, 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 '\?' for help; '\quit' to exit. MySQL JS > util.checkForServerUpgrade('root@192.168.56.88:3306', {"password":"1234qwer", "targetVersion":"8.0.26", "configPath":"/etc/my.cnf"}) The MySQL server at 192.168.56.88:3306, version 5.7.31-log - MySQL Community Server (GPL), will now be checked for compatibility issues for upgrade to MySQL 8.0.26... 1) Usage of old temporal type No issues found 2) Usage of db objects with names conflicting with new reserved keywords No issues found 3) Usage of utf8mb3 charset No issues found 4) Table names in the mysql schema conflicting with new tables in 8.0 No issues found 5) Partitioned tables using engines with non native partitioning No issues found 6) Foreign key constraint names longer than 64 characters No issues found 7) Usage of obsolete MAXDB sql_mode flag No issues found 8) Usage of obsolete sql_mode flags Notice: The following DB objects have obsolete options persisted for sql_mode, which will be cleared during upgrade to 8.0. More information: https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals global system variable sql_mode - defined using obsolete NO_AUTO_CREATE_USER option 9) ENUM/SET column definitions containing elements longer than 255 characters No issues found 10) Usage of partitioned tables in shared tablespaces No issues found 11) Circular directory references in tablespace data file paths No issues found 12) Usage of removed functions No issues found 13) Usage of removed GROUP BY ASC/DESC syntax No issues found 14) Removed system variables for error logging to the system log configuration Check failed: Invalid group at line 5 of file '/etc/my.cnf': [client] socket = /mysql/my3306/mysql.sock. More information: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-logging 15) Removed system variables Check failed: Invalid group at line 5 of file '/etc/my.cnf': [client] socket = /mysql/my3306/mysql.sock. More information: https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html#optvars-removed 16) System variables with new default values Check failed: Invalid group at line 5 of file '/etc/my.cnf': [client] socket = /mysql/my3306/mysql.sock. More information: https://mysqlserverteam.com/new-defaults-in-mysql-8-0/ 17) Zero Date, Datetime, and Timestamp values Warning: By default zero date/datetime/timestamp values are no longer allowed in MySQL, as of 5.7.8 NO_ZERO_IN_DATE and NO_ZERO_DATE are included in SQL_MODE by default. These modes should be used with strict mode as they will be merged with strict mode in a future release. If you do not include these modes in your SQL_MODE setting, you are able to insert date/datetime/timestamp values that contain zeros. It is strongly advised to replace zero values with valid ones, as they may not work correctly in the future. More information: https://lefred.be/content/mysql-8-0-and-wrong-dates/ global.sql_mode - does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates session.sql_mode - of 2 session(s) does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates 18) Schema inconsistencies resulting from file removal or corruption No issues found 19) Tables recognized by InnoDB that belong to a different engine No issues found 20) Issues reported by 'check table x for upgrade' command No issues found 21) New default authentication plugin considerations Warning: The new default authentication plugin 'caching_sha2_password' offers more secure password hashing than previously used 'mysql_native_password' (and consequent improved client connection authentication). However, it also has compatibility implications that may affect existing MySQL installations. If your MySQL installation must serve pre-8.0 clients and you encounter compatibility issues after upgrading, the simplest way to address those issues is to reconfigure the server to revert to the previous default authentication plugin (mysql_native_password). For example, use these lines in the server option file: [mysqld] default_authentication_plugin=mysql_native_password However, the setting should be viewed as temporary, not as a long term or permanent solution, because it causes new accounts created with the setting in effect to forego the improved authentication security. If you are using replication please take time to understand how the authentication plugin changes may impact you. More information: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatibility-issues https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-replication Errors: 0 Warnings: 3 Notices: 1 或其他方式: [root@mysql bin]#./mysqlsh --socket=/mysql/my3306/mysql.sock --user=root -e "util.checkForServerUpgrade()" [root@mysql bin]#./mysqlsh -- util checkForServerUpgrade root@192.168.56.88:3306 --target-version=8.0.26 --output-format=JSON --config-path=/etc/my.cnf
复制
1.2. 备份原数据库
防止升级过程中出现问题,导致数据丢失
设置 innodb_fast_shutdown=0,将数据库关闭方式调整为慢关闭, 确保数据都刷到硬盘上,更改成0,关库后进行备份。
mysql> show variables like '%innodb_fast_shutdown%'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | innodb_fast_shutdown | 1 | +----------------------+-------+ 1 row in set (0.00 sec) mysql> set global innodb_fast_shutdown=0; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%innodb_fast_shutdown%'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | innodb_fast_shutdown | 0 | +----------------------+-------+ 1 row in set (0.01 sec)
复制
逻辑备份:
[root@mysql bakup]# /mysql/base5731/bin/mysqldump -S /mysql/my3306/mysql.sock -uroot -p --all-databases --set-gtid-purged=off>/mysql/bakup/mysql5731all.sql
复制
物理备份:
查看数据目录 mysql> show global variables like '%datadir%'; +---------------+-------------------------+ | Variable_name | Value | +---------------+-------------------------+ | datadir | /mysqldata/my3306/data/ | +---------------+-------------------------+ 1 row in set (0.00 sec)
复制
1.3.下载MySQL8.0.26
https://downloads.mysql.com/archives/community/
复制
2、本地升级过程
2.1. 修改mysql配置文件
修改实际使用的目录如
#basedir=/mysql/base8026
#datadir=/mydata
2.2 升级
解压软件
[root@mysql]# xz -d mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz [root@mysql]# tar -xvf mysql-8.0.26-linux-glibc2.12-x86_64.tar [root@mysql]# chown -R mysql:mysql mysql-8.0.26-linux-glibc2.12-x86_64 [root@mysql]# mv mysql-8.0.26-linux-glibc2.12-x86_64/* ../
复制
使用新软件启动数据库
[root@mysql bin]# /mysql/base8026/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
复制
根据error.log提示进行修改 expire-logs-days=7 改: binlog_expire_logs_seconds=302400 sql_mode = STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES 改: sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION 去除以下参数: sql_mode =NO_AUTO_CREATE_USER query_cache_size = 0 query_cache_type=0 log_warnings=2 innodb_file_format=barracuda innodb_support_xa=ON
复制
若新版本小于8.0.16,那么需要使用 mysql_upgrade,之后版本不需要mysql_upgrade 修复用户表是自动完成的
当前是8.0.26,是不需要执行,执行会提示会自动完成
[root@mysql ~]# /mysql/base8026/bin/mysql_upgrade -uroot -p -S /mysql/my3306/mysql.sock Enter password: The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server. To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade. The upgrade process automatically starts on running a new MySQL binary with an older data directory. To avoid accidental upgrades, please use the --upgrade=NONE option with the MySQL binary. The option --upgrade=FORCE is also provided to run the server upgrade sequence on demand. It may be possible that the server upgrade fails due to a number of reasons. In that case, the upgrade sequence will run again during the next MySQL server start. If the server upgrade fails repeatedly, the server can be started with the --upgrade=MINIMAL option to start the server without executing the upgrade sequence, thus allowing users to manually rectify the problem.
复制
3.逻辑备份升级
3.1 安装新环境
在新目录安装新版本软件,并做初始化
3.2 旧环境做逻辑备份
/mysql/base5731/bin/mysqldump -u root -p --add-drop-table --routines --events --databases aaaa bbb --force -S /mysql/my3306/mysql.sock> /mysql/data-all.sql
复制
3.3 导入新环境
[root@mysql mysql]# /mysql/base8026/bin/mysql -u root -p < data-all.sql
复制
注:只需要导业务库,不需要导系统库,系统库导入时会报错
[root@mysql mysql]# /mysql/base8026/bin/mysql -u root -p --force < data-for-upgrade.sql Enter password: ERROR 3554 (HY000) at line 326: Access to system table 'mysql.innodb_index_stats' is rejected.
复制
导入完成后重启数据库即可
最后修改时间:2022-09-16 14:27:54
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论

2年前

评论
点赞

2年前

评论

2年前

评论
真棒
2年前

评论
相关阅读
墨天轮个人数说知识点合集
JiekeXu
417次阅读
2025-04-01 15:56:03
MySQL数据库当前和历史事务分析
听见风的声音
412次阅读
2025-04-01 08:47:17
MySQL 生产实践-Update 二级索引导致的性能问题排查
chengang
378次阅读
2025-03-28 16:28:31
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
335次阅读
2025-04-17 17:02:24
MySQL 9.3 正式 GA,我却大失所望,新特性亮点与隐忧并存?
JiekeXu
334次阅读
2025-04-15 23:49:58
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
322次阅读
2025-04-15 14:48:05
云和恩墨杨明翰:安全生产系列之MySQL高危操作
墨天轮编辑部
297次阅读
2025-03-27 16:45:26
openHalo问世,全球首款基于PostgreSQL兼容MySQL协议的国产开源数据库
严少安
281次阅读
2025-04-07 12:14:29
记录MySQL数据库的一些奇怪的迁移需求!
陈举超
184次阅读
2025-04-15 15:27:53
[MYSQL] 服务器出现大量的TIME_WAIT, 每天凌晨就清零了
大大刺猬
178次阅读
2025-04-01 16:20:44