MySql : InnoDB_Force_recovery = 1 leads to table in read only

C Morell picture C Morell · Jan 17, 2017 · Viewed 8.5k times · Source

I have an application which runs under MariaDB 10.1.18 and I had problems of data corruption. So, in my.cnf I change the parameter innoDB_force_recovery = 1 to ignore them. But then, I can not make insert in tables. But I thought that insert are forbidden when innoDB_force_recovery = 4. Is it possible to make insert when innoDB_force_recovery = 1 ? Best regards. Christophe

Answer

user149341 picture user149341 · Jan 17, 2017

Setting innodb_force_recovery=1 does not fix data corruption! It ignores corruption to allow you to back up your data before rebuilding the database.

Only set this variable to a value greater than 0 in an emergency situation, so that you can start InnoDB and dump your tables. As a safety measure, InnoDB prevents INSERT, UPDATE, or DELETE operations when innodb_force_recovery is greater than 0.

So, no. You cannot insert data while innodb_force_recovery is active. Use mysqldump to create a backup of all data, then delete the MySQL data files and use your backup to restore it.