How to Recover the Mysql Database using Binary logs

Hi Guys,
           Here I am writing the technique of recovering the mysql database using the Binary logs.This technique is very useful and very simple as per my experienced.Most of the users have loosed their data & not able to recover the data base. Please  follows the below mentioned steps.



1. Enabling the Binary logs
2. Convert binary logs into text file
3. Edit the text file & Import the text file to Mysql database

1.   First of all we have to enable the mysql binary logs for recovering the database of mysql
because when the binary logs enables then each & every operation of mysql are recorded in
binary logs by which we can restore the database easily from binary logs.

We can enable the binary logs by adding the line to file my.ini which is located on C:\Program
Files\MySQL\MySQL Server 5.0.
Below are the statement which need to be add
log -bin=d: \file-bin
where d drive is the path of binary logs where you want to store the binary logs & file-bin is
the name of binary logs.Binary logs are generated

2. The mysqlbinlog utility allows you to export data to a text file. From there, you can
sort through the text file to remove any statements that you don't want to execute. Of course,
the larger the log file, the more difficult this process can be, but there might be times when
this is the only way you can ensure that your database is fully restored. After you're satisfied
that the text file contains only the correct statements,
you can use the mysql utility to execute the statements below are command

C:\Program Files\MySQL\MySQL Server 5.0\bin> mysqlbinlog D:\file-bin.
000004> d:\test.txt.

We can also read the binary logs using command
C:\Program Files\MySQL\MySQL Server 5.0\bin>D:\file-bin.000004.


We can export the data in the log file to the text file using below command.

3. After editing the text file as necessary statement ,execute the statements in the text file
means import the text file to mysql database below is the command .




C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql –h localhost –u
root –p(password) <d:\test.txt


All SQL statements that are saved in the text file are executed. If you want to run only
statements related to a specific database, you can also use the one-database option in the
same way you saw earlier, as shown in the following example

C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql –h localhost –u
root –p(password) databasename <d:\test.txt



Regards,
Sampan Saini


Comments

  1. Get Stellar Phoenix Database Repair for MySQL utility to fix and recover corrupt MySQL databases and restore all the unreadable database objects safely, such as views, primary keys, triggers and more.

    To know more visit: http://www.mannatsoftware.com/stellar-phoenix-database-repair-for-mysql.html

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Read Excel File in VC++....

Window could not start the Apache tomcat 6 on Local Computer.For more information, review the System Events Logs.If this is a non-Microsoft service,contact service vendor, and refer to service-specific error code 0.

How to Bind Multiple SMPP Acounts Using Kannel SMS Gateway.