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
...
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)
ALTER TABLE table_name ENGINE = INNODB;
ALTER TABLE table_name REMOVE PARTITIONING;
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)
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)
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)
ALTER TABLE table_name REORGANIZE PARTITION partition_name INTO (partition_definition TABLESPACE=innodb_file_per_table);
mysqlsh -- util checkForServerUpgrade root@localhost:3307 --target-version=8.0.16 --config-path=./mysqld.cnf
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
3) 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
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
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
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
No issues found
9) ENUM/SET column definitions containing elements longer than 255 characters
No issues found
10) 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
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
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
14) Removed system variables for error logging to the system log configuration
No issues found
15) 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
16) 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
[...]
17) Schema inconsistencies resulting from file removal or corruption
No issues found
18) Issues reported by 'check table x for upgrade' command
No issues found
19) 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.
...
从以前的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 选项包括转储中的所有数据库,包括保存系统表的 数据库
用要升级的MYSQL版本初始化新数据目录(/path/to/8.0-datadir必须是空目录)
mysqld --initialize --datadir=/path/to/8.0-datadir
使用新数据目录启动MySQL 8.0服务器
mysqld_safe --user=mysql --datadir=/path/to/8.0-datadir &
重置root密码
shell> mysql -u root -p
Enter password: **** <- enter temporary root password
将先前创建的转储文件加载到新的MySQL服务器中
mysql -u root -p --force < data-for-upgrade.sql
执行任何剩余的升级操作
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不兼容的所有用户模式
启动一个新的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