1

Today morning I surprisingly found that some data is deleted form my MYSQL database, I am unable to find that data in any table.

Please suggest how to recover data from MySQL database, DOES MYSQL keeps any Log if yes where it is located? Please suggest any query to get all records.

I am using MYSQL Workbench 5.

Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108
Rohit Jape
  • 59
  • 1
  • 1
  • 7

2 Answers2

5

If you have binary logs active on your server then you can use mysqlbinlog

You can use the following:

mysqlbinlog binary_log_file > query_log.sql

If you don't have this, then you have probably lost it.

You can look here for more information on how to convert the binary logs to sql.

You can check if binary logging is enabled or not by running the following command:

SHOW VARIABLES LIKE 'log_bin';
Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108
0

For InnoDB tables, if binary logs are not enabled, there is a recovery tool provided by Percona which may help.

Created a script to automate the steps from the Percona tool which recovers the deleted rows (if exist) and provides SQL queries to load the data into database.

Please note:

The time between the deletion of rows and the database stop is crucial. If pages are reused you can’t recover the data.

VanagaS
  • 3,130
  • 3
  • 27
  • 41