これは5.6から5.7へのアップグレードのデモンストレーションです。
必要条件
- バージョン5.6のインストール
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) , Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(root@localhost)[(none)]> quit;
Bye
- バージョン 5.7 用パッケージ
lrwxrwxrwx. 1 root root 20:44 mysql -> mysql-5.6.43-linux-glibc2.12-x86_64/
drwxr-xr-x. 13 mysql mysql 20:53 mysql-5.6.43-linux-glibc2.12-x86_64
drwxr-xr-x. 10 mysql mysql 18:57 mysql-5.7.25-linux-glibc2.12-x86_64
ステップ1: 実行中のMySQLをシャットダウンします。
[root@localhost local]# service mysql stop
Shutting down MySQL.. SUCCESS!
ステップ2:ソフトリンクの削除
[root@localhost local]# unlink mysql
ステップ3: ソフトチェーンを新しいバージョンの
[root@localhost local]# ln -s mysql-5.7.25-linux-glibc2.12-x86_64/ mysql
lrwxrwxrwx. 1 root root 17:36 mysql -> mysql-5.7.25-linux-glibc2.12-x86_64/
drwxr-xr-x. 13 mysql mysql 20:53 mysql-5.6.43-linux-glibc2.12-x86_64
drwxr-xr-x. 10 mysql mysql 18:57 mysql-5.7.25-linux-glibc2.12-x86_64
ステップ4:スタートアップ
[root@localhost local]# service mysql start
Starting MySQL... SUCCESS!
[root@localhost local]# mysql
ERROR ): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost local]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.25 MySQL Community Server (GPL)
Copyright (c) , Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(root@localhost)[(none)]>
この時点でエラーログを見ると、多くのエラーが発生していることがわかります。
[root@localhost data]# vim error.log
T. [ERROR] Column count of performance_schema.events_statements_current is wrong. Expected 41, found 40. Created with MySQL 50643, now running 50725. Please use mysql_upgrade to fix this error.
T. [ERROR] Column count of performance_schema.events_statements_history is wrong. Expected 41, found 40. Created with MySQL 50643, now running 50725. Please use mysql_upgrade to fix this error.
T. [ERROR] Column count of performance_schema.events_statements_history_long is wrong. Expected 41, found 40. Created with MySQL 50643, now running 50725. Please use mysql_upgrade to fix this error.
T. [ERROR] Incorrect definition of table performance_schema.events_statements_summary_by_account_by_event_name: expected column 'USER' at position 0 to have type char(32), found type char(16).
T. [ERROR] Incorrect definition of table performance_schema.events_statements_summary_by_user_by_event_name: expected column 'USER' at position 0 to have type char(32), found type char(16).
T. [ERROR] Native table 'performance_schema'.'replication_connection_status' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'replication_applier_configuration' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'replication_applier_status' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'replication_applier_status_by_coordinator' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'replication_applier_status_by_worker' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'replication_group_member_stats' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'prepared_statements_instances' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'user_variables_by_thread' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'status_by_account' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'status_by_host' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'status_by_thread' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'status_by_user' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'global_status' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'session_status' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'variables_by_thread' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'global_variables' has the wrong structure
T. [ERROR] Native table 'performance_schema'.'session_variables' has the wrong structure
T. [ERROR] Incorrect definition of table mysql.db: expected column 'User' at position 2 to have type char(32), found type char(16).
T. [ERROR] mysql.user has no `Event_priv` column at position -: [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
T. [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.7.25' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
ログの最初の行の解釈 このテーブルにはもともと41のカラムがありましたが、現在は40しかありません!
performance_schema.events_statements_currentのカラム数が間違っています。 41を期待しましたが、40でした。 MySQL 50643で作成しましたが、現在は50725を実行しています。mysql_upgrade を使用してthisエラーを修正してください。
ステップ5: mysql_upgradeを実行してエラーを修正します。
[root@localhost bin]# ./mysql_upgrade -s -uroot -p
Enter password:
The --upgrade-system-tables option was used, databases won't be touched.
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Upgrading the sys schema.
Upgrade process completed successfully.
Checking if update is needed.
[root@localhost bin]# pwd
/usr/local/mysql/bin
[root@localhost bin]#
注:公式ドキュメントでは問題ないとされていますが、ここでは-sは元のデータ情報を更新するだけです。




