MySQL.. ERROR! The server quit without updating PID file問題解決


 不小心將服務器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= 1

然后重啟,接着報錯:

   mysqld: File './mysql-bin.index' not found (Errcode: 13)

查看data目錄下mysql-bin.index是存在的,懷疑是權限問題,對整個mysql目錄重新賦權:

chown -R mysql:mysql mysql

再次重啟,問題解決...

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM