mysql 升级所必需的有的检查

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/q375923078/article/details/100074619

  1. MYSQL5.7.22升级8.0.x
    文章目录
  2. MYSQL5.7.22升级8.0.x
    1.1. 准备升级安装
    1.1.1. 不得出现以下问题
    1.1.2. 必须没有使用没有本机分区支持的存储引擎的分区表
    1.1.3. MySQL 8.0中可能会保留一些以前未保留的关键字
    1.1.4. MySQL 5.7 mysql系统数据库中必须没有与MySQL 8.0数据字典使用的表同名的表
    1.1.5. 必须没有具有超过64个字符的外键约束名称的表
    1.1.6. 必须不是sql_mode系统变量设置中定义的过时SQL模式
    1.1.7. 必须没有包含超过255个字符或1020个字节的单个ENUM或SET列元素的表或存储过程
    1.1.8. 在升级到MySQL 8.0.13或更高版本之前,必须没有驻留在共享InnoDB表空间中的表分区 ,其中包括系统表空间和通用表空间
    1.1.9. MySQL 8.0.12或更低版本中必须没有查询和存储的程序定义,这些定义使用ASC或 DESC限定GROUP BY条款
    1.1.10. 您的MySQL 5.7安装不得使用MySQL 8.0不支持的功能。此处的任何更改都必须是特定于安装的
    1.2. Upgrade Checker
    1.3. 在Unix / Linux上升级MySQL二进制或基于包的安装
    1.3.1. 就地升级
    1.3.2. 逻辑升级
    1.4. 使用Docker部署MySQL服务器的基本步骤
    1.4.1. 就地升级
    1.4.2. 逻辑升级
    1.1. 准备升级安装
    在升级到最新的MySQL 8.0版本之前,请通过执行下面描述的初步检查来确保当前MySQL 5.7或MySQL 8.0服务器实例的升级准备情况。否则升级过程可能会失败。可以使用MySQL Shell升级检查器实用程序执行相同的检查和其他检查
    1.1.1. 不得出现以下问题
    必须没有使用过时数据类型或函数的表.
    必须没有孤立.frm文件.
    触发器不能有遗漏或空的定义者或无效的创作环境(由表示 character_set_client, collation_connection,Database Collation属性所显示 SHOW TRIGGERS或 INFORMATION_SCHEMA TRIGGERS表).
    要检查这些问题,请执行以下命令
    root@497ccc74f01a:/# mysqlcheck -uroot -proot123 --all-databases --check-upgrade
    mysqlcheck: [Warning] Using a password on the command line interface can be insecure.
    auto_increment.tb1 OK
    auto_increment.tb2 OK
    fidis_agent.agent_auth OK
    fidis_agent.agent_mapping_table OK
    fidis_agent.agent_record OK
    fidis_agent.agent_result OK
    fidis_agent.agent_rule OK
    fidis_care.mix_admin_attachment OK
    fidis_care.mix_admin_backup OK
    fidis_care.mix_admin_blacklist OK

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    1.1.2. 必须没有使用没有本机分区支持的存储引擎的分区表
    要识别此类表,请执行以下查询
    mysql> SELECT TABLE_SCHEMA, TABLE_NAME
    -> FROM INFORMATION_SCHEMA.TABLES
    -> WHERE ENGINE NOT IN (‘innodb’, ‘ndbcluster’)
    -> AND CREATE_OPTIONS LIKE ‘%partitioned%’;
    Empty set (0.17 sec)

1
2
3
4
5
6
查询报告的任何表必须更改为使用 InnoDB或未分区。要将表存储引擎更改为InnoDB,请执行以下语句
ALTER TABLE table_name ENGINE = INNODB;
1
要使分区表不分区,请执行以下语句
ALTER TABLE table_name REMOVE PARTITIONING;
1
1.1.3. MySQL 8.0中可能会保留一些以前未保留的关键字
这可能导致以前用作标识符的单词变为非法。要修复受影响的语句,请使用标识符引用
1.1.4. MySQL 5.7 mysql系统数据库中必须没有与MySQL 8.0数据字典使用的表同名的表
要识别具有这些名称的表,请执行以下查询
mysql> SELECT TABLE_SCHEMA, TABLE_NAME
-> FROM INFORMATION_SCHEMA.TABLES
-> WHERE LOWER(TABLE_SCHEMA) = ‘mysql’
-> and LOWER(TABLE_NAME) IN
-> (
-> ‘catalogs’,
-> ‘character_sets’,
-> ‘check_constraints’,
-> ‘collations’,
-> ‘column_statistics’,
-> ‘column_type_elements’,
-> ‘columns’,
-> ‘dd_properties’,
-> ‘events’,
-> ‘foreign_key_column_usage’,
-> ‘foreign_keys’,
-> ‘index_column_usage’,
-> ‘index_partitions’,
-> ‘index_stats’,
-> ‘indexes’,
-> ‘parameter_type_elements’,
-> ‘parameters’,
-> ‘resource_groups’,
-> ‘routines’,
-> ‘schemata’,
-> ‘st_spatial_reference_systems’,
-> ‘table_partition_values’,
-> ‘table_partitions’,
-> ‘table_stats’,
-> ‘tables’,
-> ‘tablespace_files’,
-> ‘tablespaces’,
-> ‘triggers’,
-> ‘view_routine_usage’,
-> ‘view_table_usage’
-> );
Empty set (0.02 sec)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
必须重命名(使用RENAME TABLE)查询报告的任何表 。这也可能需要更改使用受影响表的应用程序
1.1.5. 必须没有具有超过64个字符的外键约束名称的表
要识别具有太长约束名称的表,请执行以下查询
mysql> SELECT TABLE_SCHEMA, TABLE_NAME
-> FROM INFORMATION_SCHEMA.TABLES
-> WHERE TABLE_NAME IN
-> (SELECT LEFT(SUBSTR(ID,INSTR(ID,’/’)+1),
-> INSTR(SUBSTR(ID,INSTR(ID,’/’)+1),‘ibfk’)-1)
-> FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN
-> WHERE LENGTH(SUBSTR(ID,INSTR(ID,’/’)+1))>64);
Empty set (0.01 sec)
1
2
3
4
5
6
7
8
必须更改查询报告的任何表,使其约束名称不超过64个字符(使用 ALTER TABLE)
1.1.6. 必须不是sql_mode系统变量设置中定义的过时SQL模式
尝试使用过时的SQL模式将导致MySQL 8.0启动失败。还应修改使用过时SQL模式的应用程序以避免它们
1.1.7. 必须没有包含超过255个字符或1020个字节的单个ENUM或SET列元素的表或存储过程
之前的MySQL 8.0,的最大组合长度ENUM或SET列元素是64K。在MySQL 8.0中,单个ENUM或 SET列元素的最大字符长度为255个字符,最大字节长度为1020个字节。(1020字节限制支持多字节字符集)。在升级到MySQL 8.0之前,请修改超出新限制的任何ENUM或 SET列元素。如果不这样做会导致升级失败并显示错误
1.1.8. 在升级到MySQL 8.0.13或更高版本之前,必须没有驻留在共享InnoDB表空间中的表分区 ,其中包括系统表空间和通用表空间
通过查询来识别共享表空间中的表分区 INFORMATION_SCHEMA
mysql> SELECT DISTINCT NAME, SPACE, SPACE_TYPE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
-> WHERE NAME LIKE ‘%#P#%’ AND SPACE_TYPE NOT LIKE ‘Single’;
Empty set (0.00 sec)
1
2
3
使用以下命令将表分区从共享表空间移动到每表文件表空间 ALTER TABLE … REORGANIZE PARTITION:
ALTER TABLE table_name REORGANIZE PARTITION partition_name INTO (partition_definition TABLESPACE=innodb_file_per_table);
1
1.1.9. MySQL 8.0.12或更低版本中必须没有查询和存储的程序定义,这些定义使用ASC或 DESC限定GROUP BY条款
否则,升级到MySQL 8.0.13或更高版本可能会失败,因为可能会复制到MySQL 8.0.13或更高版本的从属服务器
1.1.10. 您的MySQL 5.7安装不得使用MySQL 8.0不支持的功能。此处的任何更改都必须是特定于安装的
MySQL 8.0中删除了一些服务器启动选项和系统变量,如果您使用其中任何一项,则升级需要更改配置
1.2. Upgrade Checker
运行示例:
mysqlsh – util checkForServerUpgrade root@localhost:3307 --target-version=8.0.16 --config-path=./mysqld.cnf
1
当调用升级检查器实用程序时,MySQL Shell将连接到服务器实例并测试准备升级安装中所述的设置,例如:
The MySQL server at example.com:3306, version
5.7.25-enterprise-commercial-advanced - MySQL Enterprise Server - Advanced Edition (Commercial),
will now be checked for compatibility issues for upgrade to MySQL 8.0.17…

  1. Usage of old temporal type
    No issues found

  2. Usage of db objects with names conflicting with reserved keywords in 8.0
    Warning: The following objects have names that conflict with reserved keywords that are new to 8.0.
    Ensure queries sent by your applications use quotes when referring to them or they will result in errors.
    More information: https://dev.mysql.com/doc/refman/en/keywords.html

dbtest.System - Table name
dbtest.System.JSON_TABLE - Column name
dbtest.System.cube - Column name

  1. 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

dbtest.view1.col1 - column’s default character set: utf8

  1. Table names in the mysql schema conflicting with new tables in 8.0
    No issues found

  2. Partitioned tables using engines with non native partitioning
    Error: In MySQL 8.0 storage engine is responsible for providing its own
    partitioning handler, and the MySQL server no longer provides generic
    partitioning support. InnoDB and NDB are the only storage engines that
    provide a native partitioning handler that is supported in MySQL 8.0. A
    partitioned table using any other storage engine must be altered—either to
    convert it to InnoDB or NDB, or to remove its partitioning—before upgrading
    the server, else it cannot be used afterwards.
    More information:
    https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-configuration-changes

dbtest.part1_hash - MyISAM engine does not support native partitioning

  1. Foreign key constraint names longer than 64 characters
    No issues found

  2. Usage of obsolete MAXDB sql_mode flag
    No issues found

  3. Usage of obsolete sql_mode flags
    No issues found

  4. ENUM/SET column definitions containing elements longer than 255 characters
    No issues found

  5. Usage of partitioned tables in shared tablespaces
    Error: The following tables have partitions in shared tablespaces. Before upgrading to 8.0 they need
    to be moved to file-per-table tablespace. You can do this by running query like
    ‘ALTER TABLE table_name REORGANIZE PARTITION X INTO
    (PARTITION X VALUES LESS THAN (30) TABLESPACE=innodb_file_per_table);’
    More information: https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals

dbtest.table1 - Partition p0 is in shared tablespace tbsp4
dbtest.table1 - Partition p1 is in shared tablespace tbsp4

  1. Circular directory references in tablespace data file paths
    No issues found

  2. Usage of removed functions
    No issues found

  3. Usage of removed GROUP BY ASC/DESC syntax
    Error: The following DB objects use removed GROUP BY ASC/DESC syntax. They need to be altered so that
    ASC/DESC keyword is removed from GROUP BY clause and placed in appropriate ORDER BY clause.
    More information: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-sql-syntax

dbtest.view1 - VIEW uses removed GROUP BY DESC syntax
dbtest.func1 - FUNCTION uses removed GROUP BY ASC syntax

  1. Removed system variables for error logging to the system log configuration
    No issues found

  2. Removed system variables
    Error: Following system variables that were detected as being used will be
    removed. Please update your system to not rely on them before the upgrade.
    More information: https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html#optvars-removed

log_builtin_as_identified_by_password - is set and will be removed
show_compatibility_56 - is set and will be removed

  1. System variables with new default values
    Warning: Following system variables that are not defined in your
    configuration file will have new default values. Please review if you rely on
    their current values and if so define them before performing upgrade.
    More information: https://mysqlserverteam.com/new-defaults-in-mysql-8-0/

back_log - default value will change
character_set_server - default value will change from latin1 to utf8mb4
collation_server - default value will change from latin1_swedish_ci to
utf8mb4_0900_ai_ci
event_scheduler - default value will change from OFF to ON
[…]

  1. Schema inconsistencies resulting from file removal or corruption
    No issues found

  2. Issues reported by ‘check table x for upgrade’ command
    No issues found

  3. 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: 7
Warnings: 32
Notices: 0

7 errors were found. Please correct these issues before upgrading to avoid compatibility issues.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
1.3. 在Unix / Linux上升级MySQL二进制或基于包的安装
1.3.1. 就地升级
1.3.2. 逻辑升级
逻辑升级涉及使用备份或导出实用程序(如mysqldump或mysqlpump)从旧MySQL实例导出SQL,安装新的MySQL服务器,以及将SQL应用于新的MySQL实例
将从先前MySQL版本中提取的SQL应用于新的MySQL版本可能会由于新的,已更改,已弃用或已删除的特性和功能引入的不兼容性而导致错误。因此,从先前的MySQL版本中提取的SQL可能需要修改才能启用逻辑升级
要在升级到最新的MySQL 8.0版本之前识别不兼容性
要执行逻辑升级
从以前的MySQL安装中导出现有数据

mysqldump -uroot -proot123 -h192.168.1.208 -P3307 --add-drop-table --routines --events --all-databases --force > data-for-upgrade.sql
如果数据库包含存储的程序, 请使用–routines和 --events选项
–all-databases 选项包括转储中的所有数据库,包括保存系统表的 数据库
1
2
3
用要升级的MYSQL版本初始化新数据目录(/path/to/8.0-datadir必须是空目录)

mysqld --initialize --datadir=/path/to/8.0-datadir
1
使用新数据目录启动MySQL 8.0服务器

mysqld_safe --user=mysql --datadir=/path/to/8.0-datadir &
1
重置root密码

shell> mysql -u root -p
Enter password: **** <- enter temporary root password
1
2
将先前创建的转储文件加载到新的MySQL服务器中

mysql -u root -p --force < data-for-upgrade.sql
1
执行任何剩余的升级操作

在MySQL 8.0.16及更高版本中,关闭服务器,然后使用–upgrade=FORCE选项重新启动它
mysqladmin -u root -p shutdown
mysqld_safe --user=mysql --datadir=/path/to/8.0-datadir --upgrade=FORCE &
重启后 --upgrade=FORCE,服务器会mysql在MySQL 5.7和MySQL 8.0之间进行系统架构中所需的任何更改 ,以便您可以利用新的权限或功能。它还为MySQL 8.0提供了最新的性能模式 INFORMATION_SCHEMA和 sys模式,并检查了与当前版本的MySQL不兼容的所有用户模式
1
2
3
1.4. 使用Docker部署MySQL服务器的基本步骤
1.4.1. 就地升级
停止MySQL 5.7服务器

1
下载MySQL 8.0 Server Docker镜像
启动一个新的MySQL 8.0 Docker容器(mysql80在此示例中命名),其中包含旧的服务器数据和配置这些容器已经保留在主机上,示例

docker run -d --name mysql8016
-v /etc/localtime:/etc/localtime
-v /data/mixlinker/mysql19129/mysql:/var/lib/mysql
-p 3306:3306
-e MYSQL_ROOT_PASSWORD=“root123”
-e MYSQL_DATABASE=“fidata”
-e MYSQL_USER=“user”
-e MYSQL_PASSWORD=“user123”
mysql:8.0.16.1
1
2
3
4
5
6
7
8
9
1.4.2. 逻辑升级
————————————————
版权声明:本文为CSDN博主「q375923078」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/q375923078/article/details/100074619

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值