How To Repair Corrupted Mysql Database Table

Repair Corrupted Mysql Database Table

In this tutorial, we will show you how to repair a corrupted MySQL database table on your Linux. Sometimes it happens that your database gets corrupted due to many reasons like it does not get restored properly or the server gets rebooted while updating the database etc and you have tried to repair it using PHPMyAdmin and it does show that it has repaired but it is not. Here is how to fix a corrupted table (note the single‘s and {} pairs are not part of the SQL commands but are used for clarity and that the “;” are required):

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step repair of corrupted MySQL DB on a Linux server.

How To Repair Corrupted Mysql Database Table

Method 1.

Step 1. Log into MySQL as administrator

mysql -uroot -p

Step 2. Select the database containing the corrupted table, i.e., ‘use {database name};’

mysql> use {database name};

Step 3. Show tables your corrupted table should be listed

mysql> show tables;

Step 4. Repair table

mysql> repair table {bad_table_name};

Method 2.

Step 1. Login to your MySQL server using Secure Shell (SSH).

Step 2. Repairing MyISAM MySQL Tables/Databases.

cd /var/lib/mysql/DBNAME
myisamchk -r -f tables.MYI

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

Congratulations! You have successfully Repair Corrupted Mysql DB. Thanks for using this tutorial to repair the corrupted MySQL Database in the Linux system. For additional help or useful information, we recommend you check the official MySQL website.

MySQL Fix Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “MySQL Fix”, starting from $10 (Paypal payment). Please contact us to get a best deal!