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

Most of the times, due to errors or bugs in the MySQL database tables, webmasters have to face various unknown issues. Whenever a database table gets corrupted, the most important thing you should do is to determine the issue behind it. It can be either because of the server crash or the database table is actually corrupted. By checking the recent /var/log/mysql.log you can verify that, what was the exact issue? And if there is such message in the log file, probably it is due to the server dying. Else, it has got corrupted because of a bug.

In this tutorial, we will go through 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) Login to your MySQL server through Secure SHell (SSH).

2) At the secure shell SSH prompt enter the following command:

mysqlcheck -r [database name]

Where, mysqlcheck is the command to check the database, -r is the command to repair the corrupted table. Replace the [databasename] with your actual database name.

MyISAM is 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 in the mysql database.

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

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

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

Like this post ?

Share on your Social Networking Profile ( Facebook, Twitter & Google+ ) and get a flat 10% Recurring discount on our VPS Hosting and Dedicated Servers.

Email us the shared link at : [email protected] or speak to our live chat operator now, by clicking on the “Live Chat” Scroller on the left-hand side of this page and we will provide you with the discount Coupon right away!

Powered by BetterDocs