2017-03-02 162 views
4

我正在本地开发并使用Mamp Pro。 基本上MySQL启动时遇到了问题,这里是错误日志中的错误消息:MySQL的故障 - InnoDB:文件操作中的操作系统错误号码2

任何想法如何解决这个问题?

2017-03-02 00:39:08 9518 [Note] Plugin 'FEDERATED' is disabled. 
2017-03-02 00:39:08 9518 [Note] InnoDB: Using atomics to ref count buffer pool pages 
2017-03-02 00:39:08 9518 [Note] InnoDB: The InnoDB memory heap is disabled 
2017-03-02 00:39:08 9518 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 
2017-03-02 00:39:08 9518 [Note] InnoDB: Memory barrier is not used 
2017-03-02 00:39:08 9518 [Note] InnoDB: Compressed tables use zlib 1.2.8 
2017-03-02 00:39:08 9518 [Note] InnoDB: Using CPU crc32 instructions 
2017-03-02 00:39:08 9518 [Note] InnoDB: Initializing buffer pool, size = 128.0M 
2017-03-02 00:39:08 9518 [Note] InnoDB: Completed initialization of buffer pool 
2017-03-02 00:39:08 9518 [Note] InnoDB: Highest supported file format is Barracuda. 
2017-03-02 00:39:08 9518 [Note] InnoDB: Log scan progressed past the checkpoint lsn 663573438 
2017-03-02 00:39:08 9518 [Note] InnoDB: Database was not shutdown normally! 
2017-03-02 00:39:08 9518 [Note] InnoDB: Starting crash recovery. 
2017-03-02 00:39:08 9518 [Note] InnoDB: Reading tablespace information from the .ibd files... 
2017-03-02 00:39:08 9518 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta uses space ID: 367 at filepath: ./affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta.ibd. Cannot open tablespace freshwp/freshwp_wfblocksadv which uses space ID: 367 at filepath: ./freshwp/freshwp_wfblocksadv.ibd 
2017-03-02 00:39:08 7fff7b652000 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 ./freshwp/freshwp_wfblocksadv.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. 
170302 00:39:08 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended 

从上面的代码误差似乎是:

2017年3月2日0点39分08秒9518 [ERROR]的InnoDB:试图打开以前打开的表空间。

上一页表affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta 使用空间ID:367 在文件路径:./affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta.ibd。

它使用空间ID不开表freshwp/freshwp_wfblocksadv能:367 在文件路径:./freshwp/freshwp_wfblocksadv.ibd

+2

这是一个非常好的错误消息。它不仅告诉你发生了什么,为什么,它还为你提供了3个关于如何解决问题的选项。你尝试过吗? (另外:为了以防万一,请先复制数据目录)。 – Solarflare

+0

在此之前发生了什么?似乎有一个崩溃和/或一些不明智的修改数据文件。 –

+0

@Solarflare是的我通过添加“innodb_force_recovery> 0”尝试了选项3,但它没有做任何事情。其他的解决方案......我只是不舒服地执行它们/不知道如何。 – Treb

回答

16

最近遇到类似的问题,本地开发W/MAMP。包含日志“数据库没有正常关闭”,该点后的类似错误消息以及建议。下面是解决它的步骤:

  1. 停止服务器为毫安
  2. 导航到你的WP数据库的.idb文件 - 如果使用甲基苯丙胺,应该是类似的地方〜/库/ Application Support/appsolute/MAMP PRO /分贝/ mysql56/[yourdbname]/
  3. 添加.bk(或任何不可识别扩展)到.idb文件名中MAMP
  4. 启动服务器的结束。如果您查看日志,您会看到一堆与找不到.idb文件相关的错误消息,但至少应该启动MySQL。在MAMP
  5. 跌落从.idb文件名称为毫安
  6. 启动服务器.bk(或任何你使用)
  7. 停止服务器 - 在这一点上,应该所有设置。

还没有做过很多与DB的工作,所以愿意丢失数据甚至重新安装MAMP;如果你的情况不同,最好先把你的数据库目录备份到一个.zip文件,这样如果你没有运气,你可以稍后再尝试其他的东西。

希望这会有所帮助。

....

UPDATE:
发现它更快地更换步骤3和6如下:
3.创建一个临时文件夹方便的位置;选择所有.idb文件并将它们移动到该文件夹​​中。
6.将文件移回到步骤2中的原始文件夹中。 ....

+1

而不是重命名.idb,您可以临时移动文件该文件夹并将其放回第6步。如果您有10个以上的表格。 :) – Cyber

0

这很好用。我只是将文件移出文件夹。对于那些使用MAMP的Mac用户,您的数据库文件可能会被隐藏。我用这个命令在终端上显示了隐藏的文件。

默认写入com.apple。finder AppleShowAllFiles -boolean true; killall查找

隐藏他们再次... 默认写com.apple.finder AppleShowAllFiles - 布尔假的; killall Finder

+0

这似乎不是问题的答案。如果它只是一个评论,你能附加它作为对原始问题的评论吗? –