ERROR 3009 (HY000): Column count of mysql.user is wrong…..

2798 ワード

バックアップリストアのテスト中に、XtraBackupを使用してデータベースをリストアした後、テストアカウントを作成中に次のエラーが発生しました.
 
 
mysql> grant all on house.* to test@'192.168.%' identified by 'test1249';
ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50620, now running 50721. Please use mysql_upgrade to fix this error.
mysql>
 
 
バックアップされたデータベースのバージョンがMySQL 5.6.20、ターゲット・データベースのMySQLのバージョンが5.7.21であるため、2つのデータベースのバージョンが一致しないため、リストア後、データベースのアップグレードを忘れてしまう(リストア後mysql_upgradeを使用してデータ構造をアップグレードしていない).実はエラーメッセージからも分かるようにmysql_を実行する必要がありますupgradeコマンドは、すべてのデータベースのすべてのテーブルが現在のバージョンのMySQLサーバと互換性がないかどうかを確認します.mysql_upgradeでは、新しいプロパティや機能を使用できるように、システムテーブルもアップグレードされます.
 
 
#  mysql_upgrade -u root -p
Enter password: 
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.db_database_info                             OK
mysql.db_instance_info                             OK
mysql.db_server_info                               OK
mysql.engine_cost                                  OK
......................................................
......................................................
Upgrade process completed successfully.
Checking if update is needed.

 
 
mysqlについてupgradeの公式紹介は以下の通りで、詳細は「4.4.7 mysql_upgrade-Check and Upgrade MySQL Table」を参照してください.
 
 
 
mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL Server. mysql_upgrade also upgrades the system tables so that you can take advantage of new privileges or capabilities that might have been added.
If mysql_upgrade finds that a table has a possible incompatibility, it performs a table check and, if problems are found, attempts a table repair. If the table cannot be repaired, see Section 2.11.3, “Rebuilding or Repairing Tables or Indexes” for manual table repair strategies.
You should execute mysql_upgrade each time you upgrade MySQL.
 
 
 
参考資料:
 
https://dev.mysql.com/doc/refman/5.7/en/mysql-upgrade.html