在MySQL 5.1中,有可能爲InnoDB存儲引擎無法完成初始化,如果在啓動過程中遇到錯誤。在那種情況下,它只是禁用InnoDB並繼續。 MyISAM表將被訪問,但是沒有InnoDB表。
檢查InnoDB存儲引擎是否已啓用。下面是從65年1月5日的情況下輸出:
mysql> show variables like 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb | YES |
+---------------+-------+
mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
. . .
接下來,我模擬了InnoDB的故障,通過編輯my.cnf中設置innodb_log_file_size=256M
,這是不是磁盤上的日誌文件的大小。然後我重新啓動實例。
mysql> show variables like 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb | NO |
+---------------+-------+
mysql> show variables like 'innodb%';
Empty set (0.00 sec)
麻煩!去哪裏看?錯誤日誌文件:
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
130218 12:50:46 [ERROR] Plugin 'InnoDB' init function returned error.
130218 12:50:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
您也可以強制MySQL如果遇到錯誤初始化InnoDB的中止其啓動,所以你永遠不會陷入這種局面再次。此項添加到在/etc/my.cnf:
[mysqld]
innodb=force
然後,當我嘗試啓動,我看到這個錯誤日誌:
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
130218 12:55:03 [ERROR] Plugin 'InnoDB' init function returned error.
130218 12:55:03 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130218 12:55:03 [ERROR] Failed to initialize plugins.
130218 12:55:03 [ERROR] Aborting
130218 12:55:03 [Note] /home/billkarwin/opt/mysql/5.1.65/bin/mysqld: Shutdown complete
在MySQL 5.5中,服務器將無法啓動如果InnoDB無法初始化。
謝謝你解決這個問題!我認爲你是對的,但問題是如何解決這個ib_logfile0問題? – fanchyna 2013-02-19 02:15:11
如果日誌文件大小是導致錯誤的原因,請嘗試將my.cnf更改爲具有磁盤上存在的文件大小。然後重新啓動mysql服務。 – 2013-02-19 06:46:35
我標記你的答案是正確的。對不起,我在看到你的答案之前採取了行動。我所做的是移動(不刪除)ib_log文件,然後重新啓動MySQL服務器。這次,innodb啓動,但是有一些錯誤信息如下:「mysql.db的列數是錯誤的,預計22,找到20.表可能已損壞。130218 21:25:03 [錯誤] mysql.user has在位置29沒有'Event_priv'列。我想我的行爲會導致一些表被破壞。有沒有簡單的解決方法?如果沒有,我可能需要重新安裝MySQL服務器並重新導入數據。你怎麼看,比爾?謝謝。 – fanchyna 2013-02-19 15:03:21