Press "Enter" to skip to content

[ERROR] InnoDB: Cannot find the dir slot for this record on that page

服务器意外掉电,数据库无法启动,启动日志报错,大概提示是上一次没有正常关机,可能有文件损坏,日志还提示需要你自己查查资料,看看怎么恢复数据库。

https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html

大概意思是mysql的自动恢复失败了,你需要在mysql的配置里面启用强制恢复模式。

[mysqld]
innodb_force_recovery = 1

官方文档写的很清楚,默认这个值是0,不会强制恢复。你可以改成 1-6中的数值,开启强制恢复。

数值越大,恢复越强硬,越可能恢复成功(启动成功,但是数据找回困难),所以建议你从1开始往大了试。不要上来就试6。从1开始试验。

文档也说明了每个恢复级别分别干啥了。

  • 1 (SRV_FORCE_IGNORE_CORRUPT)Lets the server run even if it detects a corrupt page. Tries to make SELECT * FROM tbl_name jump over corrupt index records and pages, which helps in dumping tables.
  • 2 (SRV_FORCE_NO_BACKGROUND)Prevents the master thread and any purge threads from running. If an unexpected exit would occur during the purge operation, this recovery value prevents it.
  • 3 (SRV_FORCE_NO_TRX_UNDO)Does not run transaction rollbacks after crash recovery.
  • 4 (SRV_FORCE_NO_IBUF_MERGE)Prevents insert buffer merge operations. If they would cause a crash, does not do them. Does not calculate table statistics. This value can permanently corrupt data files. After using this value, be prepared to drop and recreate all secondary indexes. Sets InnoDB to read-only.
  • 5 (SRV_FORCE_NO_UNDO_LOG_SCAN)Does not look at undo logs when starting the database: InnoDB treats even incomplete transactions as committed. This value can permanently corrupt data files. Sets InnoDB to read-only.
  • 6 (SRV_FORCE_NO_LOG_REDO)Does not do the redo log roll-forward in connection with recovery. This value can permanently corrupt data files. Leaves database pages in an obsolete state, which in turn may introduce more corruption into B-trees and other database structures. Sets InnoDB to read-only.
发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注