Mysql InnoDB CrashRecovery

Author: stephan  |  Category: Linux, Netzwerk


Symptom

Mysqlserver beendet sich selber . Auch nach einem Neustart beendet sich der Server nach wenigen Sekunden selbst

In /var/log/daemon.log befinden sich lange mysql Hexdumps sowie die Anmerkung das vermutlich die Datenbank auf Platte korrumpiert ist

Voraussetzung zur Behebung

Für solche Notfälle sollte man immer einen aktuellen mysqldump aller Datenbanken zur Hand haben. Wenn nicht kann man die Datenbank nicht ohne Datenverliste reparieren.

Lösung

Mysql mit dem dem Parameter

innodb_force_recovery = 4

starten.

So lange alle Datenbanken dropen ( mit drop Database ) bis mysql wieder ohne diesen Parameter startet.

Wenn alle Datenbanken betroffen sind muss die komplette Datenbank neuinstalliert werden . Vorher sollte /var/lib/mysql gelöscht oder umbenannt werden

Läuft die Datenbank wieder normal kann das Backup wieder eingespielt werden



Symptom

Mysqlserver is suddenly stopping (crashing) . Even after a restart the server ist stopping after a few seconds again.

In /var/log/daemon.log there are large mysql Hexdumps as well as the assumtion that the database is physically corrupt.

prerequirement for a successfull repair

In case of such an emergncy you need an uptodate mysqldump of all databases. If not, you have no change to fix the database without the loss of data

solution

restart Mysql with the Parameter

innodb_force_recovery = 4

drop your databases ( with drop Database ) as long till mysql starts normaly

If all Databases are part oft the problem, then you have to deinstall mysql , purge /var/lib/mysql , an then install mysql again.

At the latest mysql should run normal now. Time to use the dump to restore your databases.