Pages - Menu

Wednesday, August 23, 2017

How to Recover MySQL Database

It was a nightmare when my database was not backed-up and was dropped, accidently.
Fortunately, my database backed-up three months ago, i found it on the middle of nowhere. :p
Then, I recover the db with rollingback the transaction using transaction log.




so, this is my scenario.

  1. Import my last backed-up database to my brand new database name.

  2. Restore several transaction using mysqlbinlog command (use shell or command prompt to execute).
    mysqlbinlog mysql-bin.000241 mysql-bin.000242 mysql-bin.000243 mysql-bin.000244 mysql-bin.000245 mysql-bin.000246 --database=db_name | mysql -uroot -p db_name

    look at the command above, i call mysql-bin.000241 until .000246, it depends on our last database back up date/time.

  3. then, restore several transaction with datetime limit to avoid last query that drop a database.
    mysqlbinlog mysql-bin.000247 --database= db_name --stop-datetime="2016-07-18 8:01:03" | mysql -uroot -p db_name

  4. That's it, my database recovered magically....

1 comment:

  1. Playtech's 'Casinofy' casino app now live in NJ - JTHub
    › app › playtech-casinofy › app › playtech-casinofy Aug 4, 2021 — 상주 출장마사지 김제 출장안마 Aug 4, 2021 Playtech has introduced its newest mobile 고양 출장마사지 casino app to Pennsylvania, 시흥 출장샵 allowing players to bet at the 부천 출장마사지 Borgata and Atlantic City

    ReplyDelete