Wednesday, July 16, 2014

Recover & Restore Mysql Database from Crashed Server

12:30 PM

What can be done when Mysql Server got corrupted or crashed and can't able to boot mysql server, Which contain more important databases without proper backup. To avoid this situation take proper backup for mysql server in multiple ways which help you more.


                             


Follow the following steps to recover mysql database from crashed server

Step 1:

Setup a new Mysql Server with good configuration and start the service.

Step 2:

Compress the data from crashed mysql server.

First run the crashed server in recovery mode and find the data directory for mysql server with help of
mysql configuration file and by default /var/lib/mysql  is data directory for mysql server.

root@linuxstorages:~# vi /etc/my.cnf

root@linuxstorages:~#cd /var/lib

root@linuxstorages:~#zip -r mysql.zip mysql

root@linuxstorages:~#scp mysql.zip root@newserver:/root

Step 3:

Now return to the new server. Stop the mysql service

root@linuxstorages:~#service mysqld stop

Rename the new mysql data directory for backup process.

root@linuxstorages:~#cd /var/lib

root@linuxstorages:~#mv mysql mysql_backup

Step 4:

Now extract the crashed mysql.zip file in home directory and move it to default mysql data directory path.

root@linuxstorages:~#cd /root

root@linuxstorages:~#unzip mysql.zip

root@linuxstorages:~#cp -r mysql /var/lib

Step 5:

Change the ownership of the whole mysql directory.

root@linuxstorages:~#chown -R mysql:mysql  mysql/

Step 6:

Now we need to start the mysql service in safe mode to recover the mysql data in .sql format with help of mysqldump command

root@linuxstorages:~# mysqld_safe --skip-grant-tables &
 
 we can able to login mysql server as root without password in safe mode.

root@linuxstorages:~# mysql -u root

Now it's time to dump all databases. we can dump all database in single command but best way to dump is one by one so we can export and restore the important database first.

Create a new directory to save dumped database.

root@linuxstorages:~#mkdir /mysql_backup

root@linuxstorages:~#cd mysql_backup

root@linuxstorages:~#mysqldump -u root databasename > databasename.sql

After taking complete backup stop the mysql service.

Step 7:

Return new server to original mysql data setting.

root@linuxstorages:~#cd /var/lib

root@linuxstorages:~#mv mysql mysql_old

root@linuxstorages:~#mv mysql_backup mysql

Now reboot the server.

Step 8: 

Restore the database from dump.

root@linuxstorages:~#cd /mysql_backup

root@linuxstorages:~#mysql -u root -p

mysql> create database databasename;

mysql> use databasename;

mysql> source databasename.sql;

Now you have recovered your mysql data from crashed server to new server.

Written by

2 comments :

  1. Contact to Cognegic’s Exchange Database Recovery to Get MySQL Database Recovery

    In by far most of the cases we heard one request which is all things considered asked by the distinctive customers like "Is there any credibility to recover data which I eradicated accidently" is there any chance to recover those data? Regardless, for new customers it ends up hard to recover those fundamental business data and information, for this you have to contact Cognegic's DB Recovery Support or DB Recovery Services. Here our master bunch Provide completes Backup Recovery of your entire database including MongoDB, Cassandra, MySQL, and Oracle and so forth. Connect with us in a split second and get full recovery and fortification of your database.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete
  2. Step by step instructions to Recover Backup File to MySQL Database with DB Recovery Support
    Confronting reinforcement issue with respect to MySQL or not ready to recoup whole reinforcement record to MySQL database? Taking any sort of reinforcement is exceptionally basic undertaking and which isn't effortlessly recouped by the clients. It requires heaps of specialized aptitudes and capacities. Any way you can without much of a stretch recuperate your whole database with Cognegic's DB Recovery Support or Exchange Database Recovery. We at Cognegic additionally give Online Database Management Support to our top notch clients to determine their issues.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism