• 极客专栏正式上线!欢迎访问 https://www.jikewenku.com/topic.html
  • 极客专栏正式上线!欢迎访问 https://www.jikewenku.com/topic.html

MySQL 常见错误 ERROR 3009

技术杂谈 勤劳的小蚂蚁 3个月前 (01-08) 110次浏览 已收录 0个评论 扫描二维码


在测试备份还原时,使用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.

参考资料:


丨极客文库, 版权所有丨如未注明 , 均为原创丨
本网站采用知识共享署名-非商业性使用-相同方式共享 3.0 中国大陆许可协议进行授权
转载请注明原文链接:MySQL 常见错误 ERROR 3009
喜欢 (0)
[247507792@qq.com]
分享 (0)
勤劳的小蚂蚁
关于作者:
温馨提示:本文来源于网络,转载文章皆标明了出处,如果您发现侵权文章,请及时向站长反馈删除。

您必须 登录 才能发表评论!

  • 精品技术教程
  • 编程资源分享
  • 问答交流社区
  • 极客文库知识库

客服QQ


QQ:2248886839


工作时间:09:00-23:00