2017-03-02 168 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

這似乎不是問題的答案。如果它只是一個評論,你能附加它作爲對原始問題的評論嗎? –