Repairing corrupted MySQL tables

OK, so whilst using my stats monitoring software (tracewatch) it decided to bomb out on me and say the database was corrupted and needed repairing!

Example screen shot below….

corrupted table



It’s a nice simple program but I think my HDD is on the fritz so ended up getting errors all over the place and eventually received a message that it was corrupted and needed repairing

Basically the following is the commands I used to repair the database
{you must use a semicolon after each command}

– First open a command prompt (start > run > cmd) (run as admin on windows 7)
– Then change to your mysql\bin directory (i.e c:\cats\dogs\mysql\bin)
– Then enter the following command: mysql -u(yourDBUN) -p(yourdbpassword (default is root for UN)
– When logged in enter the name of your database with a semicolon following it
– If you are not sure type the command “show databases;” and press enter
– Then when you find the database type “use DBNAME;”

– Enter the below command (if you don’t know the table name {use show tables; if not sure})

show tables
– Your database should then be selected, after this enter the command “check table TABLENAME;”
– A message will probably be outputted its corrupted. Then just enter “repair table TABLENAME;” and after this everything should be repaired

table repair

Views – 1760

Leave a Reply

Your email address will not be published. Required fields are marked *