Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Steps to repair and recover innodb db if corrupted  (Read 2931 times)

0 Members and 1 Guest are viewing this topic.

Aby

  • Guest
Steps to repair and recover innodb db if corrupted
« on: November 01, 2013, 08:54:26 pm »


Steps to repair and recover innodb db if corrupted
Follow below step by step procedure to repair and recover innodb db if corrupted

********************************************************
I)Add this line to your /etc/my.cnf configuration file:
[mysqld]
innodb_force_recovery = 4

II)Restart Mysql now. Database should start, but with innodb_force_recovery in my.cnf all Insert and Update operation will be ignored.

III)Mysqldump all databases.
#mysqldump -A > dump.sql

NOTE: It is better to take dump of individual dbs

if the dump fails create a copy of current /var/lib/mysql directory
#cp -pr /var/lib/mysql /var/lib/mysql_bak

IV)Shutdown database and delete the data directory (better if you move it) and execute mysql_install_db from shell to create MySQL default tables.
#mysql_install_db

V)Remove the "innodb_force_recovery" line from your /etc/my.cnf file and restart the database.

VI)Restore everything from your backup except default 'mysql' database. For restoring the prvious user db privileges do the following.
#cp -rp /var/lib/mysql_bak/mysql /var/lib/mysql/oldmsqldb
#mysqldump oldmysqldb user > oldmysqldb_user.sql
#mysql mysql user < /var/lib/mysql/oldmysqldb_user.sql ********************************************************** Ref: http://www.softwareprojects.com/resources/programming/t-how-to-fix-mysql-database-myisam-innodb-1634.html http://webscholar.net/2010/11/07/repair-innodb-corruption-on-cpanel-mysql-server/

====