How to recover Mysql Data using ibdata1, ib_logfile0 and ib_logfile1

A couple of days ago my production (Live) Linux server was crashed. I was running Mysql in it. After making lots of efforts to recover database data, but I was unable to live mysql server back on it. I have only backup of /var/lib/mysql/ whole folder. I have copied all the contents of folder /var/lib/mysql/ (Don't copy ib_logfile0, ib_logfile1 files) in stock Linux server and follow the below steps and recover data from ibdata1, ib_logfile0 and ib_logfile1 and one by one taken backup of all database in .sql format in stock server and restore it on fresh (Production) mysql server. Don’t try these below steps on production server.

Kindly follow below steps to recover mysql database data.

STEP 1:- Installed the mysql rpm (Packages) in Linux stock server.[root@localhost ~]# yum install mysql-*

STEP 2:- Start the mysql service.
[root@localhost ~]# service mysqld start

STEP 3:- Go the directory /var/lib/ and check the ownership (permission) of mysql directory (Folder).
[root@localhost ~]# cd /var/lib/

[root@localhost lib]#ls –al

drwxr-xr-x 16 mysql mysql 4096 2003-12-02 20:36 mysql

STEP 4:- Stop the mysql service.
[root@localhost ~]# service mysqld stop

STEP 5:- Copy the ibdata1 and all database folder/directory in /var/lib/mysql/ directory. Don't copy ib_logfile0, ib_logfile1 files.

STEP 6:- Set the ownership (Permission) of all files and folders under /var/lib/mysql/ directory are mysql mysql
[root@localhost ~]# cd /var/lib/mysql/

[root@localhost mysql]# pwd
/var/lib/mysql

[root@lcoalhost mysql]# chown mysql:mysql *

STEP 7:- Start the mysql service.
[root@localhost ~]# service mysqld start

STEP 8:- Take the backup of all database one by one in .sql format and restore it to on Production mysql server.

For Mysql database backup and restoration.

http://linuxrnd.blogspot.com/2010/03/how-to-take-mysql-database-backup.html

http://linuxrnd.blogspot.com/2010/03/how-to-restore-mysql-database-backup.html

Scenario:-

Your server is crashed and got backup of /var/lib/mysql/ directory (Folder).