How to Check and Repair a Corrupted MySQL Database Table Using SSH

November 18, 2024 / MySQL Sales FAQ

This guide explains how to use MySQLcheck to repair a corrupted database table. Checking and repairing a corrupted MySQL database table using SSH ensures the integrity of the database, stopping data loss and restoring normal functionality.

Steps to repair a corrupted MySQL database table:

  1. Log in via SSH
    Access your MySQL server using Secure Shell (SSH).
  2. Run the MySQLcheck Command:
    At the root prompt, enter:

    mysqlcheck -r [database_name]
    • mysqlcheck: Checks the database.
    • -r: Repairs corrupted tables.
    • Replace [database_name] with the name of your database.
      Note: MyISAM is typically the default MySQL storage engine unless changed. This command checks and repairs all tables in the specified database.
  3. Alternative Command
    If the above command doesn’t work, try:

    myisamchk -r /var/lib/mysql/[database_name]/*
    • myisamchk: Checks the MySQL database.
    • -r: Repairs corrupted tables.
      Replace [database_name] with your database name in the path.

These steps should help you check and repair any corrupted MySQL database tables efficiently.

Once you’ve repaired your corrupted database, you can back it up or transfer it to another server. Learn how to easily export/import your MySQL databases through SSH.

Spread the love