Total size: 253 M Installed size: 253 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mysql-shell-8.0.36-1.el7.x86_64 Verifying : mysql-shell-8.0.36-1.el7.x86_64
Installed: mysql-shell.x86_64 0:8.0.36-1.el7
Complete!
打開 MySQL Shell:在你的命令行或終端中,啟動 MySQL Shell,可以看到輸出版本號為 8.0.36。
1 2 3 4 5 6 7 8 9 10
[root@shawnyan ~ 12:19:52]$ mysqlsh MySQL Shell 8.0.36
Copyright (c) 2016, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit. MySQL JS > \q Bye!
[root@shawnyan ~ 12:20:52]$ mysqlsh --mysql -uroot -h localhost --py Please provide the password for 'root@localhost': ********** Save password for 'root@localhost'? [Y]es/[N]o/Ne[v]er (default No): Y MySQL Shell 8.0.36
Copyright (c) 2016, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit. Creating a Classic session to 'root@localhost' Fetching schema names for auto-completion... Press ^C to stop. Your MySQL connection id is 12 Server version: 8.0.35 MySQL Community Server - GPL No default schema selected; type \use <schema> to set one. MySQL localhost Py > \s MySQL Shell version 8.0.36
Connection Id: 12 Current schema: Current user: root@localhost SSL: Not in use. Using delimiter: ; Server version: 8.0.35 MySQL Community Server - GPL Protocol version: Classic 10 Client library: 8.0.36 Connection: Localhost via UNIX socket Unix socket: /var/lib/mysql/mysql.sock Server characterset: utf8mb4 Schema characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 Result characterset: utf8mb4 Compression: Disabled Uptime: 18 hours 4 min 24.0000 sec
Threads: 3 Questions: 27 Slow queries: 0 Opens: 152 Flush tables: 3 Open tables: 68 Queries per second avg: 0.000
使用升級檢查工具:
在 MySQL Shell 中,你可以使用 util.checkForServerUpgrade() 函數來檢查升級兼容性。
MySQL localhost JS > util.checkForServerUpgrade(); The MySQL server at /var%2Flib%2Fmysql%2Fmysql.sock, version 8.0.35 - MySQL Community Server - GPL, will now be checked for compatibility issues for upgrade to MySQL 8.0.36...
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.
[root@shawnyan ~ 16:48:07]$ yum install ./mysql-community-* Resolving Dependencies --> Running transaction check ---> Package mysql-community-client.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-client.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-client-plugins.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-client-plugins.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-common.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-common.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-devel.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-devel.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-embedded-compat.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-embedded-compat.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-icu-data-files.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-icu-data-files.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-libs.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-libs.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-libs-compat.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-libs-compat.x86_64 0:8.0.36-1.el7 will be an update ---> Package mysql-community-server.x86_64 0:8.0.35-1.el7 will be updated ---> Package mysql-community-server.x86_64 0:8.0.36-1.el7 will be an update --> Finished Dependency Resolution ... Updated: mysql-community-client.x86_64 0:8.0.36-1.el7 mysql-community-client-plugins.x86_64 0:8.0.36-1.el7 mysql-community-common.x86_64 0:8.0.36-1.el7 mysql-community-devel.x86_64 0:8.0.36-1.el7 mysql-community-embedded-compat.x86_64 0:8.0.36-1.el7 mysql-community-icu-data-files.x86_64 0:8.0.36-1.el7 mysql-community-libs.x86_64 0:8.0.36-1.el7 mysql-community-libs-compat.x86_64 0:8.0.36-1.el7 mysql-community-server.x86_64 0:8.0.36-1.el7
Complete!
升級后檢查,由於 MySQL 已將原有的 mysql_upgrade 功能内置到 mysqld 中,默認情況如果有需要升級,會自動執行。
通過 general 日志,可以看到,新版本的 MySQL 服務器在啓動時,自動創建了新表 innodb_redo_log_files。
1 2 3 4 5 6 7 8 9 10 11 12
/usr/sbin/mysqld, Version: 8.0.36 (MySQL Community Server - GPL). started with: Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock Time Id Command Argument 2024-03-21T08:49:45.542858Z 0 Execute CREATE TABLE performance_schema.innodb_redo_log_files( `FILE_ID` BIGINT NOT NULL COMMENT 'Id of the file.', `FILE_NAME` VARCHAR(2000) NOT NULL COMMENT 'Path to the file.', `START_LSN` BIGINT NOT NULL COMMENT 'LSN of the first block in the file.', `END_LSN` BIGINT NOT NULL COMMENT 'LSN after the last block in the file.', `SIZE_IN_BYTES` BIGINT NOT NULL COMMENT 'Size of the file (in bytes).', `IS_FULL` TINYINT NOT NULL COMMENT '1 iff file has no free space inside.', `CONSUMER_LEVEL` INT NOT NULL COMMENT 'All redo log consumers registered on smaller levels than this value, have already consumed this file.' )engine = 'performance_schema'
總結一下,MySQL Shell 是升級檢查利器,這只是 MySQL Shell 强大功能的冰山一角,還有更多强大的功能,歡迎使用。