注:本文在测试环境升级测试,建议先在测试环境验证。在生产环境下还是先评估下,mysql-5.7.42为二进制方式安装,所以用mysql-8.2.0二进制包升级
1、操作环境
1、查看当前数据库版本
mysql> select@@version; +-----------+ | @@version | +-----------+ | 5.7.42 | +-----------+ 1 row in set (0.00 sec) mysql>
2、操作系统版本
[root@zyl-server ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [root@zyl-server ~]# [root@zyl-server ~]#
3、查看 Linux 系统上的 glibc(GNU C 库)版本(这里很重要,要下载对应的内核mysql版本)
ldd --version 或者 rpm -q glibc **查看当前系统中的libstdc++版本:** strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX strings /usr/lib64/libstdc++.so.6 | grep CXXABI strings /usr/lib64/libstdc++.so.6 | grep GLIBC strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
否则后面升级完成后,启动mysql会报错:
报错如下:
错误表明在启动MySQL服务时出现了一些问题。主要的错误信息是关于缺少特定库文件的版本,比如GLIBCXX_3.4.20、CXXABI_1.3.9、CXXABI_1.3.8、GLIBCXX_3.4.21以及GLIBC_2.25
。
这是由于安装的MySQL版本与系统中可用的标准库版本不兼容导致的(所以要对应下载相应的内核版本)。
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.9′ not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.8′ not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21′ not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libc.so.6: version `GLIBC_2.25′ not found (required by /usr/local/mysql/bin/../lib/private/libcrypto.so.3
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20′ not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.9′ not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.8′ not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21′ not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libc.so.6: version `GLIBC_2.25′ not found (required by /usr/local/mysql/bin/../lib/private/libcrypto.so.3
2、升级准备
1、数据备份:在升级之前,务必对当前的 MySQL 5.7 数据库进行完整备份,以防止数据丢失或损坏。确保备份文件的安全存储,并测试其可恢复性。
2、安全性考虑:建议在测试环境中进行升级测试,以模拟真实场景并检测潜在问题。这有助于减少生产环境中的不确定性和风险。
1、使用mysql-shell 检查工具检查兼容性
下载地址:https://downloads.mysql.com/archives/shell/
上传mysql-shell:
安装 mysql-shell rpm 软件包::
rpm -Uvh mysql-shell-8.2.0-1.el7.x86_64.rpm --force --nodeps
查看 mysql-shel安装版本:
mysqlsh --version
检查该版本是否可以升级到MySQL 8.2.0:
mysqlsh -uroot -p -S /tmp/mysqld.sock -e "util.checkForServerUpgrade()"
注意:mysql.sock 地址在/etc/my.cnf 文件中查看。
检查结果报告:
[root@db-mysql ~]# mysqlsh -uroot -p -S /tmp/mysqld.sock -e "util.checkForServerUpgrade()" Please provide the password for 'root@/tmp%2Fmysqld.sock': ****** Save password for 'root@/tmp%2Fmysqld.sock'? [Y]es/[N]o/Ne[v]er (default No): The MySQL server at /tmp%2Fmysqld.sock, version 5.7.42 - MySQL Community Server (GPL), will now be checked for compatibility issues for upgrade to MySQL 8.2.0... 1) Usage of old temporal type No issues found 2) MySQL 8.0 syntax check for routine-like objects No issues found 3) Usage of db objects with names conflicting with new reserved keywords No issues found 4) Usage of utf8mb3 charset Warning: The following objects use the utf8mb3 character set. It is recommended to convert them to use utf8mb4 instead, for improved Unicode support. More information: https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html db_update - schema's default character set: utf8 db_update.users.name - column's default character set: utf8 db_update.users.email - column's default character set: utf8 5) Table names in the mysql schema conflicting with new tables in 8.0 No issues found 6) Partitioned tables using engines with non native partitioning No issues found 7) Foreign key constraint names longer than 64 characters No issues found 8) Usage of obsolete MAXDB sql_mode flag No issues found 9) 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 10) ENUM/SET column definitions containing elements longer than 255 characters No issues found 11) Usage of partitioned tables in shared tablespaces No issues found 12) Circular directory references in tablespace data file paths No issues found 13) Usage of removed functions No issues found 14) Usage of removed GROUP BY ASC/DESC syntax No issues found 15) Removed system variables for error logging to the system log configuration To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary More information: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-logging 16) Removed system variables To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary More information: https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html#optvars-removed 17) System variables with new default values To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary More information: https://mysqlserverteam.com/new-defaults-in-mysql-8-0/ 18) Zero Date, Datetime, and Timestamp values No issues found 19) Schema inconsistencies resulting from file removal or corruption No issues found 20) Tables recognized by InnoDB that belong to a different engine No issues found 21) Issues reported by 'check table x for upgrade' command No issues found 22) 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 23) Columns which cannot have default values No issues found 24) Check for invalid table names and schema names used in 5.7 No issues found 25) Check for orphaned routines in 5.7 No issues found 26) Check for deprecated usage of single dollar signs in object names No issues found 27) Check for indexes that are too large to work on higher versions of MySQL Server than 5.7 No issues found 28) Check for deprecated '.
最新评论