MySQL Shell提供了一套工具集,用户可以利用这套工具集完成不同的MySQL 任务。在这一篇文章里,将为读者介绍升级检查器。
用户可以使用升级检查器来检查MySQL 5.7服务器实例,以及MySQL 8.0服务器实例与最新MySQL 8.0版本的兼容性错误和升级问题。在这里再次强调一下,使用MySQL 5.7的用户,你的MySQL该升级了。按照目前制定的产品生命周期计划,MySQL 5.7在明年10月份之后不再提供任何补丁代码,届时如果遇到安全问题,将会影响到系统的安全性。
升级检查器可以检查服务器实例的配置文件(my.cnf或my.ini)。如果存在现有的配置文件中已经定义,但在目标服务器版本中被删除的任何系统变量,或者现有的配置文件中没有定义,但在目标MySQL服务器版本中具有不同默认值的任何系统变量。升级检查器将列出相关信息。
升级检查器可以生成默认格式的输出,也可以生成JSON格式的输出,使用JSON格式可能更容易进行自动化的解析和处理。
使用该工具时,只需在MySQL Shell中执行:
util.checkForServerUpgrade (ConnectionData connectionData, Dictionary options)
注意选项部分,第一个选项用于提供连接至MySQL实例的信息,第二个选项以字典的形式提供,包括目标版本、配置路径及输出格式等内容。
举一个例子:
MySQL localhost:3310 ssl JS > util.checkForServerUpgrade('root@localhost:3310',{"targetVersion":"8.0.28"})
The MySQL server at localhost:3310, version 8.0.20 - MySQL Community Server -
GPL, will now be checked for compatibility issues for upgrade to MySQL 8.0.28...
1) Issues reported by 'check table x for upgrade' command
No issues found
Errors: 0
Warnings: 0
Notices: 0
No known compatibility errors or issues were found.
可以看到,从8.0.20升级至8.0.28是不存在不兼容现象的。
再举一个5.7的:
MySQL localhost:3306 JS > util.checkForServerUpgrade('root@localhost:3306',{"targetVersion":"8.0.28"})
Please provide the password for 'root@localhost:3306': ****
Save password for 'root@localhost:3306'? [Y]es/[N]o/Ne[v]er (default No): y
The MySQL server at localhost:3306, version 5.7.18-log - MySQL Community Server
(GPL), will now be checked for compatibility issues for upgrade to MySQL
8.0.28...
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
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
15) 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
16) 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/
17) Zero Date, Datetime, and Timestamp values
No issues found
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: 1
Notices: 1
No fatal errors were found that would prevent an upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading.
从输出报告可以看出,升级检查器在21个方面进行了检查,最终得出一个警告信息和一个提示。
通过以上的例子,读者可以发现,MySQL Shell提供的升级检查工具能够帮助用户检测版本兼容性,减轻升级工作负担。
感谢您关注“MySQL解决方案工程师”!
《深入浅出MGR》视频课程
戳此小程序即可直达B站
https://www.bilibili.com/medialist/play/1363850082?business=space_collection&business_id=343928&desc=0
文章推荐:
想看更多技术好文,点个“在看”吧!