This has been tested on Ubuntu 9.10 with MySQL 5
This is how you can check if your database tables are fine:
[code lang=“bash”]mysqlcheck -uUsername -pSecret –all-databases[/code]
Change “Username” to your username and “Secret” to your password.
To repair them, use:
[code lang=“bash”]mysqlcheck -uUsername -pSecret –all-databases –auto-repair[/code]
This requires of your MySQL daemon to be running. If it isn’t running use this to start:
[code lang=“bash”]sudo /etc/init.d/mysql start[/code]
If you have trouble running ‘mysqlcheck’, you can consider using ‘myisamchk’ instead if your tables are MyISAM. This command can be performed without MySQL daemon running. This fixes the data in your file system directly and this has saved me once.
[code lang=“bash”]sudo myisamchk –max-record-length=1048576 -o -f /var/lib/mysql/db_name/table_name.MYI[/code]
Change “db_name” to your database name and “table_name” to the name of the table you wish to repair.