First, back up the server (including the database) by creating the image. This way if anything goes wrong, you can always try again.

Then use this fast and easy fix:

mysqlcheck –repair –all-databases

Or, as is the case at Amazon account that I manage:

mysqlcheck -u root -p –repair –all-databases

Password: the root MySQL password. 

If you want to fix certain known tables:

sudo su

cd var/lib/[name of the database]

myisamchk –recover [table name]

In WordPress, you can also go to the wp-config.php:

nano /var/www/html/wp-config.php

and add this line to it:

define(‘WP_ALLOW_REPAIR’, true);

– and then go to wp-admin in the URL and click the repair link that appears there instead of the login

Of course,  you can also repair tables using a graphical user interface, such as phpMyAdmin, if it’s available.

NOTE: This will not work for InnoDB tables, however.

So, how do you repair InnoDB?

One easy way of doing it:

First, check the status of the tables, to see which ones are InnoDB based:

mysqlshow –status -u root -p <database name>

Then login to MySQL and select the database you need to fix.

Then:

create table <new table> like <old table>;

insert <new table> select * from <old table>;

truncate table <old table>;

insert <old table> select * from <new table>;

Basically, creating a new table, dumping data from old table into it. Trunkating the old table (apparently repairs it) – ad then migrating data back into it.

More detailed approach:

http://www.percona.com/blog/2008/07/04/recovering-innodb-table-corruption/