pc崩溃后Xampp mysql innodb恢复失败

Posted

技术标签:

【中文标题】pc崩溃后Xampp mysql innodb恢复失败【英文标题】:Xampp mysql innodb recovery failed after pc crash 【发布时间】:2014-04-07 08:16:27 【问题描述】:

所以我有几次遇到这个问题。我没有意识到为什么会这样,我只知道重启电脑后mysql不会启动。

所以我重新安装 xampp 并搞砸了几次,直到我得到它的工作。上次发生这种情况时,我查看了 mysql.err 文件并注意到错误与损坏的文件有关。所以我删除了那些数据库并启动了 mysql

但今天我看到了正确的理由。当它突然冻结并重新启动时,我正坐在电脑旁。之后mysql将无法启动。

查看我的 localhost/xampp 状态页面显示 mysql 已停用

去检查日志,实际上是 mysql.err 文件,它说从崩溃中恢复并且 innodb 无法从崩溃中恢复。

这是日志

2014-03-05 11:18:11 7829 mysqld_safe Starting mysqld daemon with databases from  /opt/lampp/var/mysql
2014-03-05 11:18:11 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2014-03-05 11:18:11 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-03-05 11:18:11 8235 [Note] Plugin 'FEDERATED' is disabled.
2014-03-05 11:18:11 8235 [Note] InnoDB: The InnoDB memory heap is disabled
2014-03-05 11:18:11 8235 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-03-05 11:18:11 8235 [Note] InnoDB: Compressed tables use zlib 1.2.8
2014-03-05 11:18:11 8235 [Note] InnoDB: Not using CPU crc32 instructions
2014-03-05 11:18:11 8235 [Note] InnoDB: Initializing buffer pool, size = 16.0M
2014-03-05 11:18:11 8235 [Note] InnoDB: Completed initialization of buffer pool
2014-03-05 11:18:11 8235 [Note] InnoDB: Highest supported file format is Barracuda.
2014-03-05 11:18:11 8235 [Note] InnoDB: The log sequence numbers 11011943 and 11011943 in ibdata files do not match the log sequence number 11012198 in the ib_logfiles!
2014-03-05 11:18:11 8235 [Note] InnoDB: Database was not shutdown normally!
2014-03-05 11:18:11 8235 [Note] InnoDB: Starting crash recovery.
2014-03-05 11:18:11 8235 [Note] InnoDB: Reading tablespace information from the .ibd   files...
2014-03-05 11:18:11 8235 [ERROR] InnoDB: Attempted to open a previously opened  tablespace. Previous tablespace wpdemo/wp_terms uses space ID: 93 at filepath: ./wpdemo/wp_terms.ibd. Cannot open tablespace wordpress/wp_evg_feeds which uses space ID: 93 at filepath: ./wordpress/wp_evg_feeds.ibd
2014-03-05 11:18:11 7f3ca4a11700  InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: Error: could not open single-table tablespace file ./wordpress/wp_evg_feeds.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
2014-03-05 11:18:11 7829 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/aleksandar-PC.pid ended

上次我遇到错误时我没有意识到这是因为电脑崩溃并且我不需要文件,所以我只是删除了损坏的数据库文件并启动了 mysql。问题是现在我无法删除任何文件,我需要这些数据库恢复并正常工作。 有什么建议吗?

【问题讨论】:

【参考方案1】:

因此,将损坏的文件重命名为例如 wp_terms.ibd.bkp,以便 mysql 可以跳过这些表并启动。现在当mysql恢复并启动时,我会定期关闭它。将 .bkp 文件重命名为正常的表文件并重新启动 mysql。现在,当 mysql 定期关闭时,它不会检查恢复并正常启动。应该被破坏的文件现在正在工作。一切都恢复了正常。这是什么逻辑!

【讨论】:

以上是关于pc崩溃后Xampp mysql innodb恢复失败的主要内容,如果未能解决你的问题,请参考以下文章

MySQL InnoDB 数据库使用 .frm 文件和 ibdata 文件恢复

从 Windows 10 中 XAMPP 中备份的“数据”文件夹中恢复 InnoDB 数据库

MySQL · 引擎特性 · InnoDB 崩溃恢复过程

mysql数据库无法启动恢复 mysql数据库崩溃恢复 mysql数据库恢复

MySql两大引擎InnoDB和MyISAM

强制 InnoDB 恢复,启动 MySQL 数据库