Thesql restore specific date data from a dump file

dumpmysql-5.6restore

I have mysql [version 5.6] database dump file. I want to restore only one day data from that dump file.

Anyone has any clue ?

Best Answer

You have two alternatives:

1. Load the file into a new database table and do a query for the particular date that you want.

or

2. Hand edit the dump file and load that (also in a new database).

The second alternative has several disadvantages:

  • hand editing is unreliable and error prone.

  • you may break integrity constraints - not easy to see in a load of text!

  • it's a pain in the ass :-) and will probably take you more time than alternative 1.

Conclusion:

Load the whole file - query the data you want,

CREATE my_table AS SELECT * FROM main_table
WHERE the_date = date_of_interest;

and then put that into a separate table, and then:

mysqldump db_name my_table > my_table.sql

Et voilĂ !