MySql教程

MySQL数据库无法启动,错误日志:InnoDB: Database page corruption on disk or a failed解决办法

本文主要是介绍MySQL数据库无法启动,错误日志:InnoDB: Database page corruption on disk or a failed解决办法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
   

MySQL数据库无法启动,错误日志:InnoDB: Database page corruption on disk or a failed解决办法

系统环境:
CENTOS7, XAMPP

找到日志位置:
/opt/lampp/var/mysql/instance-7srte5br.err

错误日志如下:

2018-12-16 11:22:22 140123038402368 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: The InnoDB memory heap is disabled
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: Using SSE crc32 instructions
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: Initializing buffer pool, size = 32.0M
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: Completed initialization of buffer pool
2018-12-16 11:22:22 140123038402368 [Note] InnoDB: Log sequence number at the start 365785282 and the end 365785262 do not match.
2018-12-16 11:22:22 140123038402368 [ERROR] InnoDB: Database page corruption on disk or a failed file read of tablespace /opt/lampp/var/mysql/ibdata1 page  [page id: space=0, page number=5]. You may have to recover from a backup.
2018-12-16 11:22:22 7f70efedc740 InnoDB: Page dump in ascii and hex (16384 bytes):
len 16384; hex a0a936d600000005000000000000000000000000

解决办法:
在MySQL配置/opt/lampp/etc/my.cnf里加入如下一行:

innodb_force_recovery=1

其他参数介绍:
Mode 1当遇到损坏页时,不使 MySQL 崩溃
Mode 2不运行后台操作
Mode 3不会尝试回滚事务
Mode 4不计算统计数据或应用存储/缓冲的变化
Mode 5在启动过程中不查看撤消日志
Mode 6在启动时不从重做日志(ib_logfiles)前滚

因为被破坏的地方只在索引的部分,所以当使用innodb_force_recovery = 1运行InnoDB时,操作如下:

#执行check,repair table 都无效
alter table yourtablue engine =myisam; #也报错了,因为模式是innodb_force_recovery =1。
ERROR 1025 (HY000): Error on rename of '...' to '....' (errno: -1)

#建立一张表:
create table yourtablue  #和原表结构一样,只是把INNODB改成了MYISAM。

#把数据导进去
insert into yourtablue_bak select * from email_status;

#删除掉原表:
drop table yourtablue;

#注释掉innodb_force_recovery 之后,重启。
#重命名:
rename table yourtablue_bak to yourtablue;

#最后该回存储引擎
alter table yourtablue engine = innodb

最后提醒:
为了让此类似问题不在出现,记得常常备份数据库

这篇关于MySQL数据库无法启动,错误日志:InnoDB: Database page corruption on disk or a failed解决办法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!