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


在測試備份還原時,使用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,因為兩個數據庫版本不一致,在還原過后,忘記升級數據庫(還原后沒有使用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 Tables

 

 

 

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM