I have apache and mysql running on mac os server (mavericks). I use some automation php scripts to sent queries to mysql db and also some other scripts that can be run on demand. Everything worked great, except when I tried to test what will happen if server will lose power for a moment. And.. everytime I do this database is all messed up. I can see my database and tables, but when I'm trying to access any of tables I'm getting an error that table does not exist. REPAIR and even CHECK says that tables don't exist (I checked files in mysql data folder and they're all here). I can't even remove them nor the database itself. I can see it's bad to database to break it's work like this.. but everytime? Is there any way (other than UPS) to improve mysql stability? If there's no good way to secure this maybe there're some scripts which can repair database after power loss?

Any help will be appreciated, Regards

  • There's a reason they make UPSs and why all critical servers (should) have them, and you're seeing why now. :) Jan 20, 2014 at 17:44
  • What you want is exactly what you are trying to avoid. Important servers need a UPS. There is no good way around this.
    – David
    Jan 20, 2014 at 17:54
  • So there's nothing I can do?
    – Makalele
    Jan 20, 2014 at 20:08
  • That's right; database files are open all the time. So your server should -never- lose power, because open files can get so easily corrupted; i.e. use a UPS, as everyone else has already said. And you can't predict how those files will get corrupted, so you can't plan out how to try to repair them. Millions of servers do fine with a UPS attached for just this reason. Why are you reluctant to do the practical thing?
    – Debra
    Jan 20, 2014 at 20:55

1 Answer 1


To recover corrupted data, sometimes the following commands worked well but not always, give it a try.

$ sudo mysqladmin refresh
$ sudo mysqladmin flush-tables 

Finally restart the mysql server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .