记录一次mysql修复MySQL:InnoDB错误

MySQL,InnoDB错误

错误描述:

InnoDB:Database page corruption on disk or a failed file read of page [page id:space=0,page number=624].

 

使用

innodb_force_recovery参数来恢复

innodb_force_recovery参数有6个选项具体如下

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 a crash 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.

尽量用最小的参数尝试启动,大的包含小的。

修改my.ini/my.cnf

windowsc:\ProgramData\MySQL\MySQLServer5.7路径下的my.ini

innodb_force_recovery = 1

linux/etc/my.cnf路径下的my.ini

[mysqld]
innodb_force_recovery = 1

然后再重新启动mysql,恢复正常。

使用mysqlcheck工具检查看具体哪个表的文件损坏

[root@master data]# mysqlcheck -A -u root -p
Enter password:
ht.tb                                              OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                
warning : 1 client is using or hasn't closed the table properly
status : OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
sys.sys_config                                     OK

修复表

repair table mysql.help_category

注释掉innodb_force_recovery = 1

重启

© 版权声明
THE END
喜欢就支持一下吧
点赞5赞赏 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容