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