Is there anyway to get my database back?
I've dropped it accidentally.


Yes. You can't get it back without a backup or a dump.

I haven't worked on XAMPP But it should have. This article implies that we have the binlogs.

| improve this answer | |
  • # log-bin deactivated by default since XAMPP 1.4.11 This in the my.cnf file. Which implies that nothing left. :(, Anyway it's not huge db. I'll make it again. – Omar Al-Ithawi Aug 25 '09 at 10:25
  • 1
    The best solution is "Think before DROP" ;) – Chathuranga Chandrasekara Aug 25 '09 at 10:38

Technically speaking, you can. There are data recovery companies who are able to recover most, if not all, the data that you've lost. To do this, you should immediately turn off that system and stop using it! Although it might add some additional data corruption to your disk, just switching off the power would be the best way to prevent any more writes to the disk.

Then you have to ship your computer (or just the disk) to a specialized data recovery company. They will carefully recover the data from your disk in an attempt to restore the lost database again. Whether they succeed or not, it will cost you an outrageous amount of cash. It generally depends on their hourly rates and the amount of time they need. If your data is worth $ 10.000 or more then this would be an option. They do get better results if you've immediately stopped using the disk, because every write to the disk could overwrite your deleted data.

Otherwise, see above. Data recovery is something for experts with proper tools and hardware who can make sure nothing else is written to the disk. It's real expensive and time-consuming but it is possible if you have the cash.

| improve this answer | |
  • 2
    In other words, deleted files are still on the hard disk, but only until the space is reused. – kmarsh Aug 25 '09 at 12:20
  • Thank you. But in my case it was just a small database for developing purpose. So I've made another one in matter an hour. – Omar Al-Ithawi Aug 25 '09 at 13:27
  • Yeah, I expected it to be not worth this much trouble. Still, it's good to know if you ever screw up a more expensive database. :-) – Wim ten Brink Aug 25 '09 at 14:33

If you don't have any backups or binlogs, no.

| improve this answer | |
  • It's a LAMMP (XAMPP on Linux) server. Does it have a binlogs? bcuz I don't have backup :( – Omar Al-Ithawi Aug 25 '09 at 9:38

to avoid this happening again, you need to backup your databases regularly, at least a text dump with mysqldump.

i posted a backup script that backs up every mysql db every day, and keeps the last 30 days worth of backups in How can I back up a table structure but NOT its data in MySQL

feel free to modify it for your own needs. and remember to set up a nightly cron job to run it. you can also run it from the command line just before you do anything risky to the db.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.