MySQL Bug 系统表mysql.user损坏,参数read_only=ON时,无法启动

生产环境 MySQL 机器使用备份恢复后,无法启动,报错信息为系统表 mysql.user 损坏,经过排查,发现是 MySQL 5.7 版本的一个 Bug。当 MySQL 启动时,如果 read_only 参数设置为 ON,此时如果系统表,比如 mysql.user 表发生损坏,则会导致 MySQL 无法自动修复该损坏的系统表,进而导致无法启动。

  • MySQL 版本:Percona Server for MySQL 5.7.30
  • Bug 信息:https://bugs.mysql.com/bug.php?id=100640

报错信息如下:

2021-02-02T19:42:26.275860+08:00 0 [ERROR] /usr/local/mysql/bin/mysqld: Table './mysql/user' is marked as crashed and should be repaired 2021-02-02T19:42:26.275899+08:00 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/user' is marked as crashed and should be repaired 2021-02-02T19:42:26.275914+08:00 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files. 2021-02-02T19:42:26.275944+08:00 0 [ERROR] Aborting