assaqqaf assaqqaf - 1 month ago 18
MySQL Question

Recovery after wrong MySQL update query?

I made a wrong update query in my table.

I forgot to make an id field in the

WHERE
clause.

So that updated all my rows.

How to recover that?

I didn't have a backup....

Answer

Sorry man, but the chances of restoring an overwritten MySQL database are usually close to zero. Different from deleting a file, overwriting a record actually and physically overwrites the existing data in most cases.

To be prepared if anything comes up here, you should stop your MySQL server, and make a copy of the physical directory containing the database so nothing can get overwritten further: A simple copy+paste of the data folder to a different location should do.

But don't get your hopes up - I think there's nothing that can be done really.

You may want to set up a frequent database backup for the future. There are many solutions around; one of the simplest, most reliable and easiest to automate (using at or cron in Linux, or the task scheduler in Windows) is MySQL's own mysqldump.

Comments