用mysql shell做升级前检查:
[root@node1 mysql]# yum -y isntall mysql-shell-8.0.19-1.el7.x86_64.rpm
mysql@node1:/home/db/mysql$ mysqlsh -- util check-for-server-upgrade { --user=root --host=localhost --port=13306 } --target-version=8.0.11 --config-path=/etc/my.cnf
The MySQL server at localhost:13306, version 5.7.26-log - MySQL Community
Server (GPL), will now be checked for compatibility issues for upgrade to MySQL
8.0.11...
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
Error: The following tables in mysql schema have names that will conflict
with the ones introduced in 8.0 version. They must be renamed or removed
before upgrading (use RENAME TABLE command). This may also entail changes to
applications that use the affected tables.
More information:
https://dev.mysql.com/doc/refman/8.0/en/upgrading-strategies.html#upgrade-prerequisites
mysql.catalogs - Table name used in mysql schema in 8.0
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
test.employees - 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
No issues found
11) Usage of removed functions
No issues found
12) Removed system variables
No issues found
13) 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
event_scheduler - default value will change from OFF to ON
explicit_defaults_for_timestamp - default value will change from OFF to ON
innodb_autoinc_lock_mode - default value will change from 1 (consecutive) to
2 (interleaved)
innodb_flush_neighbors - default value will change from 1 (enable) to 0
(disable)
innodb_max_dirty_pages_pct - default value will change from 75 (%) 90 (%)
innodb_max_dirty_pages_pct_lwm - default value will change from_0 (%) to 10
(%)
log_error_verbosity - default value will change from 3 (Notes) to 2 (Warning)
max_error_count - default value will change from 64 to 1024
optimizer_trace_max_mem_size - default value will change from 16KB to 1MB
performance_schema_consumer_events_transactions_current - default value will
change from OFF to ON
performance_schema_consumer_events_transactions_history - default value will
change from OFF to ON
transaction_write_set_extraction - default value will change from OFF to
XXHASH64
14) Zero Date, Datetime, and Timestamp values
No issues found
15) Schema inconsistencies resulting from file removal or corruption
No issues found
16) Table names containing 'FTS'
No issues found
17) Tables recognized by InnoDB that belong to a different engine
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: 2
Warnings: 14
Notices: 0
2 errors were found. Please correct these issues before upgrading to avoid compatibility issues.
以上很详细地说明了,升级之前要修改的错误,以及版本升级后默认参数更改的注意事项:
错误1: mysql.catalogs 与 8.0 冲突,升级之前更改表名:
use mysql
alter table catalogs rename to catalogs2 ;
错误2:test.employees - MyISAM engine does not support native partitioning
8.0 不支持 MyISAM 引擎的分区表,升级之前将分区表MyISAM引擎改为innodb
alter table test.employees engine=innodb
以json格式,展示如下:
mysqlsh -- util check-for-server-upgrade { --user=root --host=localhost --port=13306 } --target-version=8.0.11 --output-format=JSON --config-path=/etc/my.cnf
执行如下:
root@localhost 09:20:29 [mysql]>use mysql ;
root@localhost 09:20:29 [mysql]>alter table catalogs rename to catalogs2 ;
Query OK, 0 rows affected (0.02 sec)
root@localhost 09:21:26 [mysql]>alter table test.employees engine=innodb ;
Query OK, 0 rows affected (0.17 sec)
Records: 0 Duplicates: 0 Warnings: 0
解压8.0安装包,并替换5.7的:
估计是关库操作问题,官方推荐是:
a.设置innodb_fast_shutdown
SET GLOBAL innodb_fast_shutdown = 1; -- fast shutdown
SET GLOBAL innodb_fast_shutdown = 0; -- slow shutdown
b.关库
mysqladmin -u root -p shutdown
设置参数:
SET GLOBAL innodb_fast_shutdown = 1; -- fast shutdown
SET GLOBAL innodb_fast_shutdown = 0; -- slow shutdown
mysql@node1:/oracle/mysql$ mysqladmin -u root -p shutdown
mysql@node1:/oracle/mysql$ mv product product5.7
mysql@node1:/oracle/mysql$ mkdir product
mysql@node1:/oracle/mysql$ tar zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /home/db/mysql/product
mysql@node1:/oracle/mysql$ cd /home/db/mysql/product
mysql@node1:/home/db/mysql/product$ mv mysql-8.0.11-linux-glibc2.12-x86_64/* /home/db/mysql/product
mysql@node1:/home/db/mysql/product$ rm -rf mysql-8.0.11-linux-glibc2.12-x86_64
开启DB:
mysqld_safe --user=mysql --datadir=/mysqldata/data
tail -f mysql_error.log
2020-02-22T09:29:16.387832+08:00 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001287 - 'validate password plugin' is deprecated and will be removed in a future release. Please use validate_password component instead
2020-02-22T09:29:22.783263+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-02-22T09:29:22.882022+08:00 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
2020-02-22T09:29:22.882061+08:00 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
2020-02-22T09:29:22.886895+08:00 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.user].
2020-02-22T09:29:22.886923+08:00 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.db].
2020-02-22T09:29:22.886932+08:00 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.tables_priv].
2020-02-22T09:29:22.886947+08:00 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.columns_priv].
2020-02-22T09:29:22.886954+08:00 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.procs_priv].
2020-02-22T09:29:22.886961+08:00 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.proxies_priv].
2020-02-22T09:29:22.887364+08:00 0 [ERROR] [MY-013143] [Server] Column count of mysql.user is wrong. Expected 49, found 45. The table is probably corrupted
2020-02-22T09:29:22.887398+08:00 0 [Warning] [MY-010966] [Server] ACL table mysql.role_edges missing. Some operations may fail.
2020-02-22T09:29:22.887406+08:00 0 [Warning] [MY-010966] [Server] ACL table mysql.default_roles missing. Some operations may fail.
2020-02-22T09:29:22.887413+08:00 0 [Warning] [MY-010966] [Server] ACL table mysql.global_grants missing. Some operations may fail.
2020-02-22T09:29:22.887419+08:00 0 [Warning] [MY-010966] [Server] ACL table mysql.password_history missing. Some operations may fail.
2020-02-22T09:29:22.887847+08:00 0 [ERROR] [MY-010965] [Server] Missing system table mysql.global_grants; please run mysql_upgrade to create it.
2020-02-22T09:29:22.892825+08:00 0 [Warning] [MY-010727] [Server] System table 'func' is expected to be transactional.
2020-02-22T09:29:22.895676+08:00 0 [Warning] [MY-010405] [Repl] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened.
2020-02-22T09:29:22.895740+08:00 0 [ERROR] [MY-010422] [Repl] Error in checking mysql.slave_master_info repository info type of TABLE.
2020-02-22T09:29:22.895762+08:00 0 [ERROR] [MY-010415] [Repl] Error creating master info: Error checking repositories.
2020-02-22T09:29:22.895774+08:00 0 [ERROR] [MY-010426] [Repl] Slave: Failed to initialize the master info structure for channel ''; its record may still be present in 'mysql.slave_master_info' table, consider deleting it.
2020-02-22T09:29:22.895787+08:00 0 [ERROR] [MY-010529] [Repl] Failed to create or recover replication info repositories.
2020-02-22T09:29:22.911656+08:00 0 [System] [MY-010931] [Server] /home/db/mysql/product/bin/mysqld: ready for connections. Version: '8.0.11' socket: '/home/db/mysql/product/mysql.sock' port: 13306 MySQL Community Server - GPL.
以上信息正常,此时数据库已正常启动。
8.0开启成功,执行升级:
mysql@node1:/home/db/mysql$ mysql_upgrade -uroot -pRoot@0101
mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Upgrading system table data.
Checking system database.
mysql.catalogs2 OK
mysql.columns_priv OK
mysql.component OK
mysql.db OK
mysql.default_roles OK
mysql.engine_cost OK
mysql.func OK
mysql.general_log OK
mysql.global_grants OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.password_history OK
mysql.plugin OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.role_edges OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Found outdated sys schema version 1.5.1.
Upgrading the sys schema.
Checking databases.
sys.sys_config OK
test.employees OK
test.parent OK
Upgrade process completed successfully.
Checking if update is needed.
显示升级成功
重启DB:
mysqladmin -u root -pRoot@0101 shutdown
service mysqld start
mysql Ver 8.0.11 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
Connection id: 9
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.11 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /home/db/mysql/product/mysql.sock
Uptime: 1 min 22 sec
Threads: 2 Questions: 11 Slow queries: 0 Opens: 114 Flush tables: 2 Open tables: 90 Queries per second avg: 0.134
注意:
另外8.0升级成功后不能回退到5.7,只能通过逻辑恢复到5.7的版本