Rebuilding or Repairing Tables or Indexes 2.11.13 Rebuilding or Repairing Tables or Indexes Dump and Reload Method 296 mysqldump --all-databases > dump.sql mysql < dump.sql To rebuild all tables in all databases, use the  --all-databases  option: To rebuild all the tables in a single database, specify the database name without any following table name: To rebuild a table by dumping and reloading it, use  mysqldump  to create a dump file and  mysql  to reload the file: If you need to rebuild an  InnoDB  table because a  CHECK TABLE  operation indicates that a table upgrade is required, use  mysqldump  to create a dump file and  mysql  to reload the file. If the  CHECK TABLE operation indicates that there is a corruption or causes  InnoDB  to fail, refer to Section 15.21.2, “Forcing InnoDB Recovery”  for information about using the  innodb_force_recovery  option to restart  InnoDB . To understand the type of problem that  CHECK TABLE  may be encountering, refer to the  InnoDB  notes in Section 13.7.3.2, “CHECK TABLE Statement” . If you use the dump-and-reload method of rebuilding tables only for the purpose of rebuilding indexes, you can perform the dump either before or after upgrading or downgrading. Reloading still must be done afterward. If you are rebuilding tables because a different version of MySQL cannot handle them after a binary (in-place) upgrade or downgrade, you must use the dump-and-reload method. Dump the tables  before upgrading or downgrading using your original version of MySQL. Then reload the tables  after  upgrading or downgrading. This section describes how to rebuild or repair tables or indexes, which may be necessitated by: redo log files and restart the MySQL 5.7 server on the existing data directory to address the errors. The redo log files ( ib_logfile* ) reside in the MySQL data directory by default. After the errors are fixed, perform a slow shutdown (by setting  innodb_fast_shutdown=0 ) before attempting the upgrade again. •REPAIR TABLE Method •ALTER TABLE Method •Dump and Reload Method •Required table repairs or upgrades reported by  CHECK TABLE ,  mysqlcheck , or  mysql_upgrade . •Changes to how MySQL handles data types or character sets. For example, an error in a collation might have been corrected, necessitating a table rebuild to update the indexes for character columns that use the collation. Methods for rebuilding a table include: mysqldump  db_name t1 > dump.sql mysql  db_name  < dump.sql mysqldump  db_name  > dump.sql mysql  db_name  < dump.sql