How to Check and Repair a Corrupted MySQL Database Table using SSH ?

Most of the days, because of errors or bugs within the MySQL database tables, webmasters have to face various unknown problems. Whenever a database table gets corrupted, the most important thing you must do is to see the problem behind it. It will be either as a result of the server crash or the database table is gets corrupted. By checking the recent /var/log/mysql.log you’ll verify that, what was the exact issue? And if there’s such message within the log file, in all probability it’s because of the server dying. Else, it’s got corrupted as a result of a bug.

In this article, we will go to see the steps using two different commands on How to Check and Repair a Corrupted MySQL Database Table using Secure SHell (SSH) Linux command prompt ?

1) Through Secure SHell (SSH) login to your MySQL server.

2) At the secure shell SSH prompt enter the command as follow:

mysqlcheck -r [database name]

Where, to check the database mysqlcheck command is used , to repair the corrupted table -r is the command. The [databasename] should be replaced with your actual database name.

MyISAM may be a default storage engine of MySQL unless you change it. Most of the people uses MyISAM as their default engine to check and repair all the tables within the mysql database.

You can try out the following commands via the linux shell prompt, if the above commands doesn’t work for you.

myisamchk -r /var/lib/mysql/[database name]/*

Where, to check mysql database myisamchk command is used and to repair the corrupted tables -r command is used.