mysql数据库崩溃:InnoDB: Database page corruption on disk or a failed

时间:2022-06-29 06:57:06

错误情况

linux上运行的mysql突然崩溃。然后就启动不了。

查看mysql错误日志。

61111 17:24:20 mysqld_safe mysqld from pid file /home/mysql-data/bogon.pid ended
161111 17:24:46 mysqld_safe Starting mysqld daemon with databases from /home/mysql-data
161111 17:24:46 [Warning] ‘THREAD_CONCURRENCY’ is deprecated and will be removed in a future release.
161111 17:24:46 [Note] /usr[闪电]bexec/mysqld (mysqld 5.5.44-MariaDB) starting as process 14091 …
161111 17:24:46 InnoDB: The InnoDB memory heap is disabled
161111 17:24:46 InnoDB: Mutexes and rw_locks use GCC atomic builtins
161111 17:24:46 InnoDB: Compressed tables use zlib 1.2.7
161111 17:24:46 InnoDB: Using Linux native AIO
161111 17:24:46 InnoDB: Initializing buffer pool, size = 128.0M
161111 17:24:46 InnoDB: Completed initialization of buffer pool
161111 17:24:46 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 30277069237949
161111 17:24:46 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files…
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
InnoDB: Doing recovery: scanned up to log sequence number 30277072845824
InnoDB: 2 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 26141 row operations to undo
InnoDB: Trx id counter is 17BB0B00
161111 17:24:46 InnoDB: Starting an apply batch of log records to the database…
InnoDB: Progress in percents: 0 1 2 3 4 5 6 7 8 9 10 11 12 InnoDB: Database page corruption on disk or a failed

问题原因

数据库中表损坏导致数据访问错误,从而导致数据库崩溃;mysql中check table 发现表有损坏,但表是innodb类型不能修复。

Innodb 自检过程中checksum与退出时不一致便会去recover;

问题解决

1、知道mysql配置文件,my.cnf。
添加下面内容:

innodb_force_recovery=1

再启动mysql

则可以正常启动。

2、寻找到出错的表。

本人利用Navicat连接mysql服务器。

查看所有表,其中发现

表1:

mysql数据库崩溃:InnoDB: Database page corruption on disk or a failed


表2:
mysql数据库崩溃:InnoDB: Database page corruption on disk or a failed

可看到这两个表的第一行均有异常。

由于是强制启动(innodb_force_recovery=1),此时不能修改innodb引擎下的数据。

3、将这两个表导出成mysql文件。

再将这两个表删除。

复制mysql文件中的建表语句。由此新建两个与之前结构一样的表,但是存储引擎设置为MYISAM。

将mysql文件中的错误的那条语句删除。

将其他正常数据导入到数据库。

4、关闭mysql服务器。

将最开始添加的

innodb_force_recovery=1

删除。

重启mysql服务器。

将MYISAM引擎的两个表改为innodb。
(Navicat中,设计表->选项->innoDB->保存)

结束。