To repair a corrupted database / database table on Linux server command prompt / SSH shell, please follow steps below:

Repair mySQL database with mysqlcheck utility

  • Logon to your server SSH console
  • run this command

         mysqlcheck -r [your_mySQL_db_name]

  • Replace [your_mySQL_db_name] with the name of your database .
  • Where mysqlcheck is the command to check mysql database, -r is command to repair database .

Repair mySQL database with myisamchk utility

  • If mysqlcheck don't work to fix (and myism is default storage engine), please try below command:
        myisamchk -r /var/lib/mysql/[your_mySQL_db_name]/*
  • Replace [your_mySQL_db_name] with the name of your database .
  • Where myisamchk is the command to check mysql database, -r is command to repair database .

Please note: MyISAM is a default storage engine of MySQL, unless you change it. Mostly MyISAM is set as default engine to check and repair all the tables in the mysql database.

Was this answer helpful? 11 Users Found This Useful (11 Votes)