Skip to main content
Solved

Repair Database Table via Terminal

  • March 9, 2013
  • 6 replies
  • 35 views

Forum|alt.badge.img+3

It's taking forever to repair the Database Tables, and I'm not certain the process continues after I'm timed out of the web interface. Is it possible to repair the database tables from the command line?

Best answer by Sonic84

You can use the mysqlcheck command to perform several operations including check, repair and/or optimize.

example:
mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
http://dev.mysql.com/doc/refman/5.0/en/mysqlcheck.html

6 replies

Forum|alt.badge.img+12
  • Valued Contributor
  • Answer
  • March 9, 2013

You can use the mysqlcheck command to perform several operations including check, repair and/or optimize.

example:
mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
http://dev.mysql.com/doc/refman/5.0/en/mysqlcheck.html


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • March 11, 2013

Thanks Sonic84!


Forum|alt.badge.img
  • New Contributor
  • April 12, 2016

How to auto repair all databases with mysqlcheck

$ mysqlcheck -u root --auto-repair --all-databases
--auto-repair If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.
--all-databases Check all the databases. This is the same as --databases with all databases selected.

donmontalvo
Forum|alt.badge.img+36
  • Hall of Fame
  • July 24, 2016

Thought I'd post these commands here, in case anyone needs to first do a full backup of MySQL, then check and repair all databases.

First command does a full backup of MySQL, this includes all databases, all GRANTs, etc.
Second command outputs a log so you can peruse table maintenance success, since Command Prompt on Windows doesn't seem to let you scroll up through the whole enchilada output.

mysqldump -u root -p<password> --all-databases > database_backup.sql
mysqlcheck -u root -p<password> --auto-repair --check --all-databases > database_backup.txt

Forum|alt.badge.img+7
  • Contributor
  • August 29, 2016

removed -wrong posting


Forum|alt.badge.img+1
  • New Contributor
  • April 2, 2025

You can easily repair a database table using the DRS Softech MySQL Database Repair Tool in just a few simple steps:

  1. Download & Install the tool on your system.

  2. Launch the software and select the corrupted MySQL database.

  3. Click on Scan to analyze and repair the damaged tables.

  4. Preview the recoverable data before saving.

  5. Click on Save to restore the repaired tables.