Home » Mysql » Undo a mysql UPDATE command

Undo a mysql UPDATE command

Posted by: admin January 31, 2018 Leave a comment

Questions:

I was trying to do an update on the MySQL server and accidentally forgot to add an additional WHERE clause which was supposed to edit one row.

I now have 3500+ rows edited due to my error.

I may have a back up but I did a ton of work since the last backup and I just dont want to waste it all because of 1 bad query.

Please tell me there is something i can do to fix this.

Answers:

If you committed your transaction, it’s time to dust off that backup, sorry. But that’s what backups are for. I did something like that once myself… once.

Questions:
Answers:

Just an idea – could you restore your backup to a NEW database and then do a cross database query to update that column based on the data it used to be?

Questions:
Answers:

Nothing.

Despite this you can be glad that you’ve got that learning experience under your belt and be proud of how you’ll now change your habits to greatly reduce the chance of it happening again. You’ll be the ‘master’ now that can teach the young pups and quote from actual battle-tested experience.