mysql.user table is damaged. Please run mysql_upgrade

NeilZhang
NeilZhang
管理员
140
文章
106.8千
浏览
Linux MySQL评论2,034字数 983阅读3分16秒阅读模式

I have forgot why I upgraded my blog to PHP7 and MySQL5.7, but I just did it.

First have to say, even I had no upgrade plan for such thing. At that time I thought I could upgrade the MySQL rpm to 5.7, then started MySQL database and it should upgrade my database automatically. The worse thing was that I upgraded the PHP to version 7 at the same time, and some modules were not installed at the beginning.

After the upgrade, I rebooted the server and tried to access my website, while just got a blank page. From the log of Nginx, I found the socket file was changed after the php-fpm update, then I changed it accordingly. While still got blank page, and from the error log of php-fpm, I found the json extension of PHP was not installed, so I installed it and some other extensions, then restarted the php-fpm service, and got an error message that the database could not be connected.

From the log of mysql service, I got the error like the title of this blog. So after the upgrade, the mysqld could not be started. I searched and this one saved me:

MySQLd doesn't start after brew upgrade from 5.6 to 5.7

So the steps to fix this issue are easy:

  1. run as mysql user:
  2. ---one session---
  3. /usr/sbin/mysqld --skip-grant-tables
  4. ---another session---
  5. /usr/bin/mysql_upgrade
  6. killall mysqld

I post the log of command '/usr/bin/mysql_upgrade' as below:

  1. -bash-4.1$ /usr/bin/mysql_upgrade
  2. Checking if update is needed.
  3. Checking server version.
  4. Running queries to upgrade MySQL server.
  5. Checking system database.
  6. mysql.columns_priv OK
  7. mysql.db OK
  8. mysql.engine_cost OK
  9. mysql.event OK
  10. mysql.func OK
  11. mysql.general_log OK
  12. mysql.gtid_executed OK
  13. mysql.help_category OK
  14. mysql.help_keyword OK
  15. mysql.help_relation OK
  16. mysql.help_topic OK
  17. mysql.host OK
  18. mysql.innodb_index_stats OK
  19. mysql.innodb_table_stats OK
  20. mysql.ndb_binlog_index OK
  21. mysql.plugin OK
  22. mysql.proc OK
  23. mysql.procs_priv OK
  24. mysql.proxies_priv OK
  25. mysql.server_cost OK
  26. mysql.servers OK
  27. mysql.slave_master_info OK
  28. mysql.slave_relay_log_info OK
  29. mysql.slave_worker_info OK
  30. mysql.slow_log OK
  31. mysql.tables_priv OK
  32. mysql.time_zone OK
  33. mysql.time_zone_leap_second OK
  34. mysql.time_zone_name OK
  35. mysql.time_zone_transition OK
  36. mysql.time_zone_transition_type OK
  37. mysql.user OK
  38. Upgrading the sys schema.
  39. Checking databases.
  40. blog.wp_commentmeta OK
  41. blog.wp_comments
  42. error : Table upgrade required. Please do "REPAIR TABLE `wp_comments`" or dump/reload to fix it!
  43. blog.wp_links
  44. error : Table upgrade required. Please do "REPAIR TABLE `wp_links`" or dump/reload to fix it!
  45. blog.wp_options OK
  46. blog.wp_postmeta OK
  47. blog.wp_posts
  48. error : Table upgrade required. Please do "REPAIR TABLE `wp_posts`" or dump/reload to fix it!
  49. blog.wp_term_relationships OK
  50. blog.wp_term_taxonomy OK
  51. blog.wp_termmeta OK
  52. blog.wp_terms OK
  53. blog.wp_usermeta OK
  54. blog.wp_users
  55. error : Table upgrade required. Please do "REPAIR TABLE `wp_users`" or dump/reload to fix it!
  56. sys.sys_config OK
  57. wiki.archive OK
  58. wiki.category OK
  59. wiki.categorylinks
  60. error : Table rebuild required. Please do "ALTER TABLE `categorylinks` FORCE" or dump/reload to fix it!
  61. wiki.change_tag OK
  62. wiki.externallinks OK
  63. wiki.filearchive OK
  64. wiki.hitcounter OK
  65. wiki.image OK
  66. wiki.imagelinks OK
  67. wiki.interwiki OK
  68. wiki.ipblocks OK
  69. wiki.iwlinks OK
  70. wiki.job OK
  71. wiki.l10n_cache OK
  72. wiki.langlinks OK
  73. wiki.log_search OK
  74. wiki.logging OK
  75. wiki.module_deps OK
  76. wiki.msg_resource OK
  77. wiki.msg_resource_links OK
  78. wiki.objectcache
  79. error : Table rebuild required. Please do "ALTER TABLE `objectcache` FORCE" or dump/reload to fix it!
  80. wiki.oldimage OK
  81. wiki.page OK
  82. wiki.page_props OK
  83. wiki.page_restrictions OK
  84. wiki.pagelinks OK
  85. wiki.protected_titles OK
  86. wiki.querycache OK
  87. wiki.querycache_info OK
  88. wiki.querycachetwo OK
  89. wiki.recentchanges OK
  90. wiki.redirect OK
  91. wiki.revision OK
  92. wiki.searchindex OK
  93. wiki.site_identifiers OK
  94. wiki.site_stats OK
  95. wiki.sites OK
  96. wiki.tag_summary OK
  97. wiki.templatelinks OK
  98. wiki.text OK
  99. wiki.transcache OK
  100. wiki.updatelog OK
  101. wiki.uploadstash OK
  102. wiki.user OK
  103. wiki.user_former_groups OK
  104. wiki.user_groups OK
  105. wiki.user_newtalk OK
  106. wiki.user_properties OK
  107. wiki.valid_tag OK
  108. wiki.watchlist OK
  109.  
  110. Repairing tables
  111. blog.wp_comments
  112. Note : TIME/TIMESTAMP/DATETIME columns of old format have been upgraded to the new format.
  113. status : OK
  114. blog.wp_links
  115. Note : TIME/TIMESTAMP/DATETIME columns of old format have been upgraded to the new format.
  116. status : OK
  117. blog.wp_posts
  118. Note : TIME/TIMESTAMP/DATETIME columns of old format have been upgraded to the new format.
  119. status : OK
  120. blog.wp_users
  121. Note : TIME/TIMESTAMP/DATETIME columns of old format have been upgraded to the new format.
  122. status : OK
  123. `wiki`.`categorylinks`
  124. Running : ALTER TABLE `wiki`.`categorylinks` FORCE
  125. status : OK
  126. `wiki`.`objectcache`
  127. Running : ALTER TABLE `wiki`.`objectcache` FORCE
  128. status : OK
  129. Upgrade process completed successfully.
  130. Checking if update is needed.

When I restarted mysql service, finally I could open my website again.

One more thing was about the W3TC plugin. When I wanted to change the cache service to others, I always got error message that it could not create directory under wp-content/cache folder. I confirmed the nginx user had read and write permissions of this folder but I still got the error. I could not find any error log about it, so at last I had to grant the 777 to the cache folder, then I found a tmp directory was created and the user name was php-fpm. So I knew I should grant write permission to php-fpm user, and this could be finished by 'setfacl -m u:php-fpm:rwx cache'.

Finally I got an error-free WordPress blog, but I needed to upgrade the wiki part. mysql.user table is damaged. Please run mysql_upgrade

OK, let me have a rest, and upgrade it in another day.

 

 
  • 本文由 NeilZhang 发表于15/04/2017 16:37:11
  • Repost please keep this link: https://www.dbcloudsvc.com/blogs/linux/mysql-user-table-is-damaged-please-run-mysql_upgrade/
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定