【问题处理】MySQL无法启动

问题现象

MySQL服务无法启动,找到MySQL安装目录下的error.log日志文件,发现有如下报错(以下报错内容已删除时间信息):

1
2
3
4
5
6
[ERROR] InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 4081619513 and the end 4081620530.
[ERROR] InnoDB: Plugin initialization aborted with error Generic error
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Failed to initialize plugins.
[ERROR] Aborting

问题分析

1.分析日志

报错日志最开始是missing MLOG_CHECKPOINT,可能是某些记录文件损坏导致启动MySQL服务失败。

2.搜索相关问题处理方法

经过搜索关键词MySQL missing MLOG_CHECKPOINT,找到如下相关解决方案:

  1. MySQL Server shuts down frequently and won’t start again now
  2. mysql报错Ignoring the redo log due to missing MLOG_CHECKPOINT between
  3. InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT

解决方案

通过阅读以上解决方案,最终确定使用删除实例下的ib_logfile*文件(与error.log应该在同一目录下),我这删除的是ib_logfile0ib_logfile1文件,然后重启MySQL服务。

重启后MySQL服务可正常使用,但是在error.log日志中出现以下报错(以下报错内容已删除时间信息):

1
2
3
4
5
...
[ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.
[ERROR] InnoDB: Page [page id: space=6617, page number=12] log sequence number 4081502626 is in the future! Current system log sequence number 4080904753.
[ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.
...

根据日志提示,访问:https://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
(发现有中文翻译版

打开是MySQL官方提供的解决方案,大意是两种处理方式

  1. 可以启动服务的情况下,使用SELECT ... INTO OUTFILE导出数据,再进行数据恢复
  2. 不可以启动服务的情况下,通过修改my.inimy.cnf配置文件中的innodb_force_recovery配置来启动服务,再进行数据导出和恢复。

中心思想就是先把服务启动起来,再导出数据后重新导入数据。

那么现在MySQL服务可以启动,就这样做:

  1. 导出数据库的SQL脚本
  2. 删除数据库
  3. 导入步骤1的数据库SQL脚本

以上操作,不涉及MySQL服务相关的表,例如:information_schema mysql performance_schema sys

出于安全起见,建议恢复后立即备份数据,并导入到新实例中。


评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×