How to Repair a MySQL Database Through Linux and Windows Command Line?

This article describes how to repair MySQL database tables through Linux and Windows command line.

Repair MySQL Database through Linux Terminal(SSH)

  1. Login to your Linux VPS using Secure Shell (SSH) and connect to MySQL from the command line.

    mysql -uUsername -p // Replace Username with your username.


  2. Enter MySQL user password and hit Enter. You will see mysql prompt appearing. Now, in order to display all databases, type following command at mysql prompt.

    show databases;
  3. mysqlcheck enables you to check databases without stopping the entire MySQL service. -r argument is used to repair the corrupted tables. mysqlcheck utility efficiently works on both MyISAM and InnoDB database engines. Enter following command to repair MySQL database.

    mysqlcheck -r [database] // Replace database name with your database name.

Repair MySQL Database through Windows Command Line

  1. Login to your Windows VPS using Remote Desktop. Please refer to how to connect Windows VPS using RDP.

  2. Go to Start and locate Command Prompt. Right click Command Prompt and select Run as Administrator option.

  3. At windows command prompt navigate to MySQL bin directory as follows.

    cd C:\Program Files\MySQL\MySQL Server 5.5\bin  //  Replace your MySQL bin directory path here.
  4. Run the following command to start the MySQL prompt.

    mysql -u root -p
  5. Enter MySQL root password when you are being asked.

  6. You will see mysql prompt appearing. Now, to display all databases, type following command at mysql prompt:

    show databases;
  7. Enter the following command to repair MySQL database.

    mysqlcheck -r [database] // Replace database name with your database name.

Related Articles

How to convert time zone in MySQL?

You can change the timezone in MySQL using php function CONVERT_TZ. Following is the SQL command...

How to rename MySQL Database from cPanel?

cPanel offers MySQL Database rename option. Renaming MySQL Database requires while migrating...

How to set ut8mb4 for mysql via phpMyAdmin?

Please refer to the following steps to change MySQL server collation via phpMyAdmin Login to...

Fix :: Unable to login in phpMyadmin after revoking MySQL root user

Problem Statement I am not able to login into phpMyadmin after revoking root user. Solution...

Fix - PHPMyAdmin Error You should upgrade to MySQL 5.5.0 or later

Problem statement Recently we upgraded phpMyAdmin version from 4.0.10.12 to 4.5.3.1 in our...

  • 1 Users Found This Useful

Was this answer helpful?