背景

        操作系统Windows        软件版本MYSQL5.7.2

MySQL崩溃之后,无法启动,日志打印错误:

2020-08-06T12:11:24.667962Z 0 [Warning] option 'wait_timeout': unsigned value 31536000 adjusted to 2147483
2020-08-06T12:11:24.667962Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-08-06T12:11:24.667962Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2020-08-06T12:11:24.667962Z 0 [Note] mysqld (mysqld 5.7.20-log) starting as process 2140 ...
2020-08-06T12:11:24.714762Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2020-08-06T12:11:24.714762Z 0 [Note] InnoDB: Uses event mutexes
2020-08-06T12:11:24.714762Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2020-08-06T12:11:24.714762Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2020-08-06T12:11:24.714762Z 0 [Note] InnoDB: Number of pools: 1
2020-08-06T12:11:24.714762Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2020-08-06T12:11:24.714762Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-08-06T12:11:24.730362Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-08-06T12:11:24.745962Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-08-06T12:11:24.745962Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-08-06T12:11:24.745962Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-08-06T12:11:24.964363Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-08-06T12:11:24.964363Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-08-06T12:11:24.964363Z 0 [ERROR] Failed to initialize plugins.
2020-08-06T12:11:24.964363Z 0 [ERROR] Aborting

2020-08-06T12:11:24.964363Z 0 [Note] Binlog end
2020-08-06T12:11:24.964363Z 0 [Note] Shutting down plugin 'CSV'
2020-08-06T12:11:24.964363Z 0 [Note] mysqld: Shutdown complete


异常有效日志

2020-08-06T12:11:24.745962Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-08-06T12:11:24.745962Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-08-06T12:11:24.745962Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-08-06T12:11:24.964363Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-08-06T12:11:24.964363Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-08-06T12:11:24.964363Z 0 [ERROR] Failed to initialize plugins.


解决方案

进入MySQL数据库数据文件夹data的目录,删除文件ib_logfile0, ib_logfile1,然后重新启动MySQL

采用指令启动mysqld.exe --defaults-file=F:\WebServer\mysql-5.7.20-winx64\mysql-5.7.20-winx64\my.ini


程序启动之后,打印日志

2020-08-07T08:44:03.157806Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 6364172
2020-08-07T08:44:03.158801Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 6364181
2020-08-07T08:44:03.159799Z 0 [Note] InnoDB: Database was not shutdown normally!
2020-08-07T08:44:03.160796Z 0 [Note] InnoDB: Starting crash recovery.
2020-08-07T08:44:03.364253Z 0 [ERROR] InnoDB: Page [page id: space=0, page number=7] log sequence number 17142644237 is in the future! Current system log sequence number 6364190.
2020-08-07T08:44:03.365249Z 0 [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.
2020-08-07T08:44:03.368241Z 0 [ERROR] InnoDB: Page [page id: space=0, page number=2] log sequence number 17142553980 is in the future! Current system log sequence number 6364190.
2020-08-07T08:44:03.369239Z 0 [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.
2020-08-07T08:44:03.371234Z 0 [ERROR] InnoDB: Page [page id: space=0, page number=4] log sequence number 14215691586 is in the future! Current system log sequence number 6364190.
2020-08-07T08:44:03.372231Z 0 [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.
202

说明:MySQL数据库产生了损坏,目前暂时没有通过日志分析出更多有用的信息,例如到底是那张表写库失败,是否是系统忽然断电等问题