Recover/Repair InnoDB tables in MySQL

Databases could be left in an inconsistent state if a server crashes. While there are numerous tools to fix MyISAM tables in MySQL, InnoDB repair is not always as simple. MySQL may refuse to start-up, resulting in indefinite downtime. If your MySQL error logs reveal an InnoDB corruption, proceed with caution.

As a part of server management, our support teams are dealing with similar issues and successfully recovered many corrupted InnoDB tables.

Initial Steps

First and foremost, isolate the database and create a backup. Stop the webserver (which will prevent any new database transactions) and block external access to MySQL port 3306 (if you have allowed remote access). Make sure there are no more transactions running by using the “mysqladmin” binary or utility.

Then, back up the entire MySQL data folder, or, if space is an issue, backup all the InnoDB files (those beginning with *.ib).

After that, start the MySQL server and, if it comes up online, take a SQL dump with the mysql dump binary.

Use InnoDB recovery to bring the server back online if MySQL keeps crashing on normal boot. Change the value of “InnoDB force recovery” in /etc/my.cnf to get the MySQL server back online, start with value “1” and work your way up to value “6.” Take a SQL dump once the server is back online.

If you can’t get a dump done, your next best choice is to use the daily backups of the affected databases that you have.

Database Restoration Process

Remove the corrupt databases and the recovery settings from /etc/my.cnf after you have a working database dump.

Restart the MySQL service and check that the error log no longer contains any errors.

You can now use the SQL dump to restore the databases.

mysql < /path/to/backup/recovered_db.sql

Always be Precautions

Servers can crash for a variety of causes, including hardware failure, heavy server load, and so on. As a result, InnoDB could be corrupted in any such situation. As previously said, we can utilize recovery mode to recover databases, however, this is not always successful.

Thus, the next best choice is a solid daily backup, which should always be available. Configure your server to do daily database backups and conduct periodic audits to ensure that the backups are complete.

Another key step is to enable InnoDB database error monitoring. Third-party or custom-developed plugins for monitoring systems like Nagios and Zabbix can detect InnoDB faults via error logs or applications like “mysqlcheck.”

If you are facing any issues with InnoDB corrupt or crash, Our technical team will be available anytime to recover your data.

FREE SERVER AUDITING

Get Auditing Report of Your Server for FREE!!