- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯(lián)網(wǎng)協(xié)會(huì )理事單位
- 安全聯(lián)盟認證網(wǎng)站身份V標記
- 域名注冊服務(wù)機構許可:滇D3-20230001
- 代理域名注冊服務(wù)機構:新網(wǎng)數碼
mysql崩潰無(wú)法啟動(dòng):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 問(wèn)題: 重啟服務(wù)器后MySQL數據庫崩潰了無(wú)法啟動(dòng)。 查看錯誤日志,如下: 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 ./data_dep/report.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. 2、問(wèn)題分析: 從日志中可以看出是innodb引擎出了問(wèn)題。日志里提示到 Error: could not open single-table tablespace file ./data_dep/report.ibd ,通過(guò)這個(gè)報錯信息可以判斷出來(lái),mysql丟失這個(gè)數據文件,或者是該數據文件損壞,當mysql啟動(dòng)的時(shí)候檢測有問(wèn)題,將進(jìn)行恢復,提示正?;謴驮摂祿募?,日志中也提供了解決方法,有強制恢復的方法。在mysql的配置文件my.cnf里找到 [mysqld]字段下,添加 innodb_force_recovery=1 my.cnf代碼如下: [mysqld] innodb_force_recovery = 1 innodb_force_recovery參數說(shuō)明: 如果innodb_force_recovery = 1不生效,則可嘗試2——6幾個(gè)數字 然后重啟mysql,重啟成功。然后使用mysqldump或 pma 導出數據,執行修復操作等。修復完成后,把該參數注釋掉,還原默認值0。 配置文件的參數:innodb_force_recovery innodb_force_recovery影響整個(gè)InnoDB存儲引擎的恢復狀況。默認為0,表示當需要恢復時(shí)執行所有的恢復操作(即校驗數據頁(yè)/purge undo/insert buffer merge/rolling back&forward),當不能進(jìn)行有效的恢復操作時(shí),mysql有可能無(wú)法啟動(dòng),并記錄錯誤日志; innodb_force_recovery可以設置為1-6,大的數字包含前面所有數字的影響。當設置參數值大于0后,可以對表進(jìn)行select,create,drop操作,但insert,update或者delete這類(lèi)操作是不允許的。 1(SRV_FORCE_IGNORE_CORRUPT):忽略檢查到的corrupt頁(yè)。 2(SRV_FORCE_NO_BACKGROUND):阻止主線(xiàn)程的運行,如主線(xiàn)程需要執行full purge操作,會(huì )導致crash。 3(SRV_FORCE_NO_TRX_UNDO):不執行事務(wù)回滾操作。 4(SRV_FORCE_NO_IBUF_MERGE):不執行插入緩沖的合并操作。 5(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存儲引擎會(huì )將未提交的事務(wù)視為已提交。 6(SRV_FORCE_NO_LOG_REDO):不執行前滾的操作 注:當前進(jìn)行innodb_force_recovery設置為1時(shí)啟動(dòng)mysql數據庫,在數據恢復后,需要再innodb_force_recovery修改正常模式,也就是innodb_force_recovery=0。 3、解決辦法: 方法一 建立一張新表: create table demo_bak #和原表結構一樣,只是把INNODB改成了MYISAM。 把數據導進(jìn)去 insert into demo_bak select * from demo; 刪除掉原表: drop table demo; 注釋掉 innodb_force_recovery 之后,重啟。 重命名: rename table demo_bak to demo; 最后改回存儲引擎: alter table demo engine = innodb 方法二 使用mysqldump將表格導出,然后再導回到InnoDB表中。這兩種方法的結果是相同的。 備份導出(包括結構和數據): mysqldump -uroot -p123 test > test.sql 還原方法1: use test; source test.sql 還原方法2(系統命令行): mysql -uroot -p123 test < test.sql; 注意,CHECK TABLE命令在InnoDB數據庫中基本上是沒(méi)有用的。 方法三 a、配置my.cnf 配置innodb_force_recovery = 1或2——6幾個(gè)數字,重啟MySQL b、導出數據腳本 mysqldump -uroot -p123 test > test.sql 導出SQL腳本?;蛘哂肗avicat將所有數據庫/表導入到其他服務(wù)器的數據庫中。 注意:這里的數據一定要備份成功。然后刪除原數據庫中的數據。 c、刪除ib_logfile0、ib_logfile1、ibdata1 備份MySQL數據目錄下的ib_logfile0、ib_logfile1、ibdata1三個(gè)文件,然后將這三個(gè)文件刪除 d、配置my.cnf 將my.cnf中innodb_force_recovery = 1或2——6幾個(gè)數字這行配置刪除或者配置為innodb_force_recovery = 0,重啟MySQL服務(wù) e、將數據導入MySQL數據庫 mysql -uroot -p123 test < test.sql; 或者用Navicat將備份的數據導入到數據庫中。 此種方法下要注意的問(wèn)題: (1)ib_logfile0、ib_logfile1、ibdata1這三個(gè)文件一定要先備份后刪除; (2)一定要確認原數據導出成功了 (3)當數據導出成功后,刪除原數據庫中的數據時(shí),如果提示不能刪除,可在命令行進(jìn)入MySQL的數據目錄,手動(dòng)刪除相關(guān)數據庫的文件夾或者數據庫文件夾下的數據表文件,前提是數據一定導出或備份成功。
售前咨詢(xún)
售后咨詢(xún)
備案咨詢(xún)
二維碼
TOP