不當心將服務器OS給重啓了,再啓動數據庫的時候,出現了很奇怪的問題
[root@dev run]# service mysql restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/run/mysql.pid).
沒法啓動mysql,後來上網找了一下解決方法,無非就是如下幾種
1. 註釋/etc/my.cnf裏的skip-federated註釋掉即#skip-federated;
2. my.cnf文件配置太高,從新定義其中的參數(根據服務器狀況定義);
3. 殺掉mysql_safe和mysqld進程,而後再重啓;
4. 當前日誌文件過大,超出了my.cnf中定義的大小(默認爲64M),刪除日誌文件再重啓;
可是在主機中:
1. 註釋中無skip-federated這個選項
2. My.cnf是本身優化過的,斷電以前正常使用,不是這個的問題
3. Ps –ef | grep mysql 根本就沒有mysql的殭屍進程
4. 沒有這個問題
基本上網上的全部方式都試過了,都沒法解決問題,而後在數據庫的data目錄(mysql/data)查看錯誤日誌,個人服務器是localhost.localdomain.err文件,也多是
(/var/lib/mysql/log/error.log)
2014-06-10 11:52:46 15921 [Note] InnoDB: Database was not shutdown normally!
2014-06-10 11:52:46 15921 [Note] InnoDB: Starting crash recovery.
2014-06-10 11:52:46 15921 [Note] InnoDB: Reading tablespace information from the .ibd files...
2014-06-10 11:52:46 15921 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace raildb/base_company_fullname uses space ID: 4 at filepath: ./raildb/base_company_fullname.ibd. Cannot open tablespace mysql/slave_master_info which uses space ID: 4 at filepath: ./mysql/slave_master_info.ibd
2014-06-10 11:52:46 7ff29246d720 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 ./mysql/slave_master_info.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.
140610 11:52:46 mysqld_safe mysqld from pid file /var/lib/mysql/run/mysql.pid ended
第一處標黃,提示是數據庫沒有正常關閉
第二處標藍,提示正在從.ibd files讀取tablespace information
第三處標紅,就是開始error的地方,大概意思就是讀取不到raildb這個庫的tablespace
下邊說的就是一些處理這個問題的方法,就不一一翻譯了
最後我感受是由於斷電以前,mysql沒有正常關閉,形成了raildb這個庫的一些異常,我採用的解決方法是在innoDB,強制覆蓋
Vi /etc/my.cof 增長一行 innodb_force_recovery= 1mysql
而後重啓,接着報錯:sql
mysqld: File './mysql-bin.index' not found (Errcode: 13)數據庫
查看data目錄下mysql-bin.index是存在的,懷疑是權限問題,對整個mysql目錄從新賦權:服務器
chown -R mysql:mysql mysqlapp
再次重啓,問題解決...dom