手机看片精品高清国产日韩,色先锋资源综合网,国产哺乳奶水91在线播放,乱伦小说亚洲色图欧洲电影

幫助中心 >  技術知識庫 >  云服務器 >  服務器教程 >  mysql崩潰無法啟動:InnoDB 3) If the file system or the disk is broken, and you cannot remove InnoDB the .ibd file

mysql崩潰無法啟動:InnoDB 3) If the file system or the disk is broken, and you cannot remove InnoDB the .ibd file

2023-11-23 11:03:16 6628

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
問題:
重啟服務器后MySQL數據庫崩潰了無法啟動。
查看錯誤日志,如下:
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丟失這個數據文件,或者是該數據文件損壞,當mysql啟動的時候檢測有問題,將進行恢復,提示正常恢復該數據文件,日志中也提供了解決方法,有強制恢復的方法。在mysql的配置文件my.cnf里找到 [mysqld]字段下,添加 innodb_force_recovery=1
my.cnf代碼如下:
[mysqld]
innodb_force_recovery = 1
innodb_force_recovery參數說明:
如果innodb_force_recovery = 1不生效,則可嘗試2——6幾個數字
然后重啟mysql,重啟成功。然后使用mysqldump或 pma 導出數據,執行修復操作等。修復完成后,把該參數注釋掉,還原默認值0。
配置文件的參數:innodb_force_recovery
innodb_force_recovery影響整個InnoDB存儲引擎的恢復狀況。默認為0,表示當需要恢復時執行所有的恢復操作(即校驗數據頁/purge undo/insert buffer merge/rolling back&forward),當不能進行有效的恢復操作時,mysql有可能無法啟動,并記錄錯誤日志;
innodb_force_recovery可以設置為1-6,大的數字包含前面所有數字的影響。當設置參數值大于0后,可以對表進行select,create,drop操作,但insert,update或者delete這類操作是不允許的。
1(SRV_FORCE_IGNORE_CORRUPT):忽略檢查到的corrupt頁。
2(SRV_FORCE_NO_BACKGROUND):阻止主線程的運行,如主線程需要執行full purge操作,會導致crash。
3(SRV_FORCE_NO_TRX_UNDO):不執行事務回滾操作。
4(SRV_FORCE_NO_IBUF_MERGE):不執行插入緩沖的合并操作。
5(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存儲引擎會將未提交的事務視為已提交。
6(SRV_FORCE_NO_LOG_REDO):不執行前滾的操作
注:當前進行innodb_force_recovery設置為1時啟動mysql數據庫,在數據恢復后,需要再innodb_force_recovery修改正常模式,也就是innodb_force_recovery=0。

3、解決辦法:
方法一
建立一張新表:
create table demo_bak  #和原表結構一樣,只是把INNODB改成了MYISAM。
把數據導進去
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數據庫中基本上是沒有用的。
方法三
a、配置my.cnf
配置innodb_force_recovery = 1或2——6幾個數字,重啟MySQL
b、導出數據腳本
mysqldump -uroot -p123 test > test.sql
導出SQL腳本。或者用Navicat將所有數據庫/表導入到其他服務器的數據庫中。
注意:這里的數據一定要備份成功。然后刪除原數據庫中的數據。
c、刪除ib_logfile0、ib_logfile1、ibdata1
備份MySQL數據目錄下的ib_logfile0、ib_logfile1、ibdata1三個文件,然后將這三個文件刪除
d、配置my.cnf
將my.cnf中innodb_force_recovery = 1或2——6幾個數字這行配置刪除或者配置為innodb_force_recovery = 0,重啟MySQL服務
e、將數據導入MySQL數據庫
mysql -uroot -p123 test < test.sql; 或者用Navicat將備份的數據導入到數據庫中。
此種方法下要注意的問題:
(1)ib_logfile0、ib_logfile1、ibdata1這三個文件一定要先備份后刪除;
(2)一定要確認原數據導出成功了
(3)當數據導出成功后,刪除原數據庫中的數據時,如果提示不能刪除,可在命令行進入MySQL的數據目錄,手動刪除相關數據庫的文件夾或者數據庫文件夾下的數據表文件,前提是數據一定導出或備份成功。


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: