Get the App
SLTechnology News&Howtos  ›  Database  › 

Innodb_force_recovery forcibly fixes MySQL abnormal shutdown problem

Shulou Source: shulou.com Published: 2022-06-01 21:13:08 09月27日 Update

1. Add the following code to the mysql configuration file my.cnf: [mysqld] innodb_force_recovery=1 # can set 1-6innodb_purge_thread=0 # if the above configuration value is greater than 1, set it to 0 here, otherwise there will be errors in the configuration file parameters of InnoDB: Waiting for the background threads to start: innodb_force_recoveryinnodb_force_recovery affects the recovery status of the entire InnoDB storage engine. The default is 0, which means that all recovery operations (that is, check data pages / purge undo/insert buffer merge/rolling back&forward) are performed when recovery is needed, and mysql may not be able to start and log errors when valid recovery operations cannot be performed; innodb_force_recovery can be set to 1-6, with large numbers including the impact of all previous numbers. When the setting parameter value is greater than 0, you can select,create,drop the table, but operations such as insert,update or delete are not allowed. 1 (SRV_FORCE_IGNORE_CORRUPT): ignore checked corrupt pages. 2 (SRV_FORCE_NO_BACKGROUND): blocking the running of the main thread, if the main thread needs to perform full purge operations, will result in crash. 3 (SRV_FORCE_NO_TRX_UNDO): no transaction rollback operation is performed. 4 (SRV_FORCE_NO_IBUF_MERGE): merge operations that insert buffers are not performed. 5 (SRV_FORCE_NO_UNDO_LOG_SCAN): without viewing the redo log, the InnoDB storage engine treats uncommitted transactions as committed. 6 (SRV_FORCE_NO_LOG_REDO): roll forward is not performed. 2. Restart the database, log in to MySQL backup data mysqldump-uroot-p-- all-databases > back.sql3, comment out the two lines of code previously added in the my.cnf file, delete all files in the / var/lib/mysql/ directory, restart MySQL, and restart successfully. 4. Re-execute MySQL's security script mysql_secure_installation, set the root login password, and then log in to MySQL to restore the database. Source back.sql (absolute path to backup files)

Tags: File data login configuration transaction code parameters backup engine number database log thread error storage impact effective security success above Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei MariaDB Docker OPPO Reno