I have a raspberry pi with MySQL installed.

I turn off my raspberry Pi by unplugging the power (no system shutdown).

At some points the MySQL get infected, and after that it will never turn on again.

it gives me this error on startup checking for tables which need an upgrade are corrupt or were not closed cleanly

how can I fix that without "system shutdown" is there any query I can run to prevent this or is there any better alternative to MySQL (maybe a light version!) ?

thank you

1 Answer 1


how can I fix that without "system shutdown"

You cannot.

is there any...

No, there isn't. No operating system in the world is designed to absorb having the cord pulled without a shutdown. If you keep doing this, you will find db corruption is only one of a wide range of possible problems.

The purpose of software like MySQL is to provide high performance access to a database. To do that, the software must manage state, and part of that is cleanly shutting down. Software is not magical, it follows logical principles, and it cannot predict an arbitrary power outage.

You could do that just for MySQL with:

`service mysql stop`

But in this case you might as well just use shutdown now because that will A) stop mysql for you, B) also take care of all those other potential problems.1 It takes <2 seconds.

So to be clear: You CANNOT manage the system by just yanking the power cord. You MUST shut it down properly. There is no advice, blog, or tutorial about any alternative to this because there CANNOT be any. It is not possible. Period. Do not waste your time trying to make 2 + 2 = 5.

1 Preventing db corruption will be an academic exercise if something more essential is corrupted and the system then fails to boot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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