Word To The Wise
18 Mar 2008Always, Always, Always start your MySQL update query with the limit and the where clause, even if you've done the query a thousand times before.
The one time you screw it up, it will be on a Friday evening, when you're just trying to do one last thing for the day before you head home, and when most of the office has gone home.
Oh, and it'll be a database of 30 million DNS records and you'll manage to wipe them all out.
Yep, that's why I did last Friday. I was stupid and working too fast, and managed to hit the ' and Enter in quick succession, as they sit next to eat other on the keyboard. Caught my mistake when it wiped out "only" 13k records on the master database, but the query had already replicated out and managed to take out the slaves.
My saving grace is that we've got a couple of great folks in our sysadmin group, and they helped me get things back from a backup pretty quickly.
But yeah, that was scary. And not fun. Now I've been on both sides. I've helped people recover from a disaster ... and I've caused a huge disaster. Go me.