Support Online
Skip to main content

MySQL Table Repair

What Will You Learn in This Guide?

This guide teaches you how to detect corrupted tables in MySQL databases.
Explains different recovery methods for MyISAM and InnoDB tables.
Shows safe backup steps to prevent data loss.

Technical Summary

Main topic: MySQL corrupted table repair
Solved problem: Unreadable tables and server crash
Methods: Backup, MyISAM repair, InnoDB recovery


1. Security Priority: Data Backup

Be sure to back up the data directory before starting the repair.
This step seriously reduces the risk of data loss.

Stop MySQL Service

sudo systemctl stop mysql
  • This command ensures that the MySQL service stops safely.

Backup Data Directory


cp -r /var/lib/mysql /var/lib/mysql_bkp
  • This command backs up all database files.

2. Repairing MyISAM Tables

  1. Supports manual repair of MyISAM tables.
  • Check the table status first.

Checking the Table


CHECK TABLE tablo_adi;
  • This query reports whether the table is corrupt or not.

Repairing the Table


REPAIR TABLE tablo_adi;
  • This query attempts to automatically repair the MyISAM table.

3. Recovering InnoDB Tables

  1. InnoDB tables are usually auto-rolled. If the server does not boot, a forced recovery is required.

  2. Restart MySQL Service


sudo systemctl restart mysql
  • This action triggers automatic recovery of InnoDB.

4. Data Recovery with InnoDB Force Recovery

  1. If the server still does not boot, force recovery is used.

Open Configuration File


sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
  • This file contains the MySQL main configuration.

Enable Recovery Mode


[mysqld]
innodb_force_recovery=1
  • This setting allows MySQL to open with corrupted data.

5. Dump & Reload

  1. Data can be recovered if the table is accessed.

  2. Export the Table


mysqldump veritabani_adi tablo_adi > yedek_dosyasi.sql
  • This command takes the table as a logical backup.

Delete Corrupted Table


mysql -u kullanici -p --execute="DROP TABLE veritabani_adi.tablo_adi"
  • This command removes the corrupt table.

Restore Table


mysql -u kullanici -p < yedek_dosyasi.sql
  • This command recreates the table cleanly.

Frequently Asked Questions (FAQ)

1. How do I know if the table is corrupted? The Table is marked as crashed error is common.

2. Can innodb_force_recovery be increased? Yes, 1–6 can be tried. The risk increases.

3. What should be done after the repair? The force_recovery line must be removed.

4. Which engine is more secure? InnoDB is more robust than MyISAM.


Result

MyISAM tables require manual repair. InnoDB tables recover themselves most of the time. Regular backup is the most critical security step.

You can try the GenixNode infrastructure now to run your MySQL databases safely, quickly and stable.