How to repair a corrupted mysql database table

How do you repair a corrupt MySQL table?

Error: Table ‘tbl_ name’ doesn’t exist databasename_tablesname.frm can’t open
If you get either of the following errors, it usually means that no table exists in the current database with the given name:
Table ‘tbl_name’ doesn’t exist
Can’t find file: ‘tbl_name’ (errno: 2)

1 ) Check the permission and ownership of database i.e. it should be same below

drwx—— 2 mysql mysql cpanelusername_dbname.

2) If the permission are corrects but same error occurs then it seems that your database table may be corrupts then there are following way to repair the DB

a) Go to whm >>SQL Services >> Repair a Database >> select database name and click Repair Database.

b) Go to cpanel >> mysql section MySQL Account Maintenance >> search database then click on Repair.

C) You can repair it though shell when mysqld server is running

i) login in mysql to that particular user by using following command

mysql>mysql –u databaseusername –p databasename

ii) select particular database

mysql> use databasename;

iii) Check whether database table is corrupted or not if following command output shows null value then it should be corrupts otherwise it is fine

mysql>show table status like ‘table name’\G; Or

mysql>check table tablename ;

iv)If it is corrupts then use the following command to repair that particular database table.

mysql>repair table tablename;

D] You can repair it though shell when mysqld server is not running

Repairing MyISAM mySQL Tables/Databases:

# cd /var/lib/mysql/DBNAME

# myisamchk tablename.MYI

Repairing ISAM mySQL Tables/Databases:

# cd /var/lib/mysql/DBNAME

isamchk tablename.MYI


-c –> check database is corrupted or not

-r –> recorver

-o –> optimise the database

Tagged . Bookmark the permalink.

One Response to How to repair a corrupted mysql database table

  1. I am doing research for my college thesis, thanks for your useful points, now I am acting on a sudden impulse.

    – Laura

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.