MySQL: Table is marked as crashed and should be repaired

Filed in Uncategorized 6 comments

English version below

Mir ist grad aufgefallen das meine comments Tabelle von WordPress kaputt ist. phpMyAdmin hat mir folgendes gesagt:

Table 'usr_web1_1/wp_comments' is marked as crashed and should be repaired.

phpMyAdmin

phpMyAdmin hatt selber schon Funktionen zur Reperatur von Tabellen an Board. Unter Tabelle > Operations > Table Maintenance findet man diverse Möglichkeiten zur Fehlerbehebung:

  • Check table
  • Analyze table
  • Repair table
  • Optimize table

Bei mir waren die Funktionen aber nicht verfügbar. Es erschien immer nur die obige Fehlermeldung. Der Fehlerteufel schein wohl hartnäckiger zu sein als ich dachte. Ok, werd ich auch hartnäckiger und versuche es per SSH:

SSH

  1. root@host:~# /etc/init.d/mysql stop
  2. Stopping MySQL database server: mysqld.
  3. root@host:~# /etc/init.d/mysql start
  4. Starting MySQL database server: mysqld.
  5. Checking for corrupt, not cleanly closed and upgrade needing tables..

Hmm… phpMyAdmin zeigt mir immernoch den gleichen Fehler an.
Weiter gehts mit

mysqlcheck

  1. root@host:~# mysqlcheck -A  -r -uUSER -pPASSWORD

-A sorgt dafür das alles überprüft wird und -r sorgt dafür das auch versucht wird, kaputte Tabellen zu reparieren.
Dies hat leider auch nix gebracht. Jetzt habe ich schon gedacht das ich die Tabelle löschen muss und wieder neu anlegen muss. Damit währen dann aber die Kommentare von WordPress weg, das wollte ich natürlich nicht. Zum Glück hab ich noch etwas gegoogelt und hab eine Lösung bei think eMeidi Blog gefunden. Man nehme die Brachialmethode

myisamchk

Erstmal nochmal den MySQL Server runterfahren:

  1. /etc/init.d/mysql stop

und dann

  1. myisamchk /var/lib/mysql/usr_web1_1/wp_comments.MYI
  2. Checking MyISAM file: /var/lib/mysql/usr_web1_1/wp_comments.MYI
  3. myisamchk: warning: Table is marked as crashed
  4. - check file-size
  5. []
  6. myisamchk: error: Recordlink that points outside datafile at 1,2,3,4
  7. MyISAM-table 'wp_comments.MYI' is corrupted
  8. Fix it using switch "-r" or "-o"

Gesagt, getan:

  1. myisamchk -r /var/lib/mysql/usr_web1_1/wp_comments.MYI
  2. - recovering (with sort) MyISAM-table 'smt_stats.MYI'
  3. Data records: 27
  4. - Fixing index 1
  5. - Fixing index 2
  6. - Fixing index 3
  7. - Fixing index 4

Soweit so gut, alles nochmal überprüfen:

  1. myisamchk /var/lib/mysql/usr_web1_1/wp_comments.MYI
  2. Checking MyISAM file: /var/lib/mysql/usr_web1_1/wp_comments.MYI

Da alles soweit gut aussieht, fahren wir den MySQL Server wieder hoch:

  1. /etc/init.d/mysql start

Nun schauen wir nochmal bei phpMyAdmin nach und siehe da, alles wieder da und funktioniert auch wieder einwandfrei!

English Version:

Today i realized that my WordPress Comments Table are crashed. phpMyAdmin throw me following error message:

Table 'usr_web1_1/wp_comments' is marked as crashed and should be repaired.

phpMyAdmin

phpMyAdmin has a build-in repair function. Go to Table > Operations > Table Maintenance and you find some possibilities for repairing a crashed table:

  • Check table
  • Analyze table
  • Repair table
  • Optimize table

But these functions wasn’t available for my table. Only the error message from above appears. Ok, the problem seems to be a little bit more difficult. Let’s try to fix this via SSH:

SSH

  1. root@host:~# /etc/init.d/mysql stop
  2. Stopping MySQL database server: mysqld.
  3. root@host:~# /etc/init.d/mysql start
  4. Starting MySQL database server: mysqld.
  5. Checking for corrupt, not cleanly closed and upgrade needing tables..

Hmm… phpMyAdmin shows furthermore the error message. Next try: mysqlcheck

mysqlcheck

  1. root@host:~# mysqlcheck -A  -r -uUSER -pPASSWORD

-A for all Tables and -r is for repairing

This does not repair my table. Same error message… But befor I delete and recreate the wp_comments table (and lost all comments), I ask Google. I find a solution at think eMeidi Blog. Let’s try the last chance!

myisamchk

First we need to stop the MySQL Server:

  1. /etc/init.d/mysql stop

and then

  1. myisamchk /var/lib/mysql/usr_web1_1/wp_comments.MYI
  2. Checking MyISAM file: /var/lib/mysql/usr_web1_1/wp_comments.MYI
  3. myisamchk: warning: Table is marked as crashed
  4. - check file-size
  5. []
  6. myisamchk: error: Recordlink that points outside datafile at 1,2,3,4
  7. MyISAM-table 'wp_comments.MYI' is corrupted
  8. Fix it using switch "-r" or "-o"

Ok, lets try to repair with -r switch

  1. myisamchk -r /var/lib/mysql/usr_web1_1/wp_comments.MYI
  2. - recovering (with sort) MyISAM-table 'smt_stats.MYI'
  3. Data records: 27
  4. - Fixing index 1
  5. - Fixing index 2
  6. - Fixing index 3
  7. - Fixing index 4

Seems to be ok, let’s check again.

  1. myisamchk /var/lib/mysql/usr_web1_1/wp_comments.MYI
  2. Checking MyISAM file: /var/lib/mysql/usr_web1_1/wp_comments.MYI

Now we only need to start the MySQL server again:

  1. /etc/init.d/mysql start

Finally let’s take a look in phpMyAdmin. No error message anymore! All repaired :) I hope this help you

Posted by badmad   @   6 Oktober 2008 6 comments
Tags : , , , , ,

Share This Post

RSS Digg Twitter StumbleUpon Delicious Technorati

6 Comments

Comments
Okt 9, 2008
20:47
#1 Tom :

Danke! Genau das wonach ich gesucht habe! Ich dachte schon ich muss die Datenbank löschen

Dez 10, 2008
14:45
#2 matthias :

genial!
Dankeschön das hat mir ne datenbank wieder zum laufen gebracht
guter Blog!

Author Dez 11, 2008
10:51
#3 badmad :

dafür ist der Eintrag da :)

Nov 19, 2009
10:54
#4 Lars :

Ich konnte den mysqld nicht herunterfahren, da mir die entsprechenden Rechte fehlen. Nach weiterer Recherche stieß ich auf den mysql-Befehl REPAIR TABLE, der aus MySQL heraus genau das gleiche macht wie myisamchk. Zum Ausführen dieses Befehls braucht man SELECT und INSERT privileges auf die entsprechende Tabelle.

Author Nov 19, 2009
11:14
#5 badmad :

Das ist nicht ganz korrekt. In der MySQL Referenz steht zu REPAIR TABLE: “(REPAIR TABLE does not implement all the options of myisamchk.)” Somit kann es unter umständen, wie bei mir damals, dazu kommen, dass REPAIR TABLE nicht ausreicht.

Jul 6, 2010
12:47
#6 bacci :

Super !!! Danke, bei mir war genau das gleiche, hatte nach Pleskupdate probleme und bin an meine Datenbanken nur noch über den mysql ordner rangekommen, durch die WM2010 Tipps durfte natürlich nichts verloren gehen. Hab dann ein älteres Backup wiederhergestellt die Datenbankdateien bzw. den ganzen Ordner wieder zurückkopiert und dann eben diesen Fehler gehabt. Mit deiner Anleitung läuft es wieder super !!

Danke nochmals

lG. bacci

Leave a Comment

Name

Email

Website

Previous Post
«
Next Post
»
EXULT designed by ZENVERSE  |  In conjunction with Reseller Hosting from the #1 Web Hosting Provider - HostNexus.