在测试备份还原时,利用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.
参考资料: