content_image/665412.jpg
## ALTER TABLE Method 

To rebuild a table with ALTER TABLE , use a “null”  alteration; that is, an ALTER TABLE  statement that “changes”  the table to use the storage engine that it already has. For example, if t1  is an InnoDB  table, use this statement: 

ALTER TABLE t1 ENGINE = InnoDB; 

If you are not sure which storage engine to specify in the ALTER TABLE  statement, use SHOW CREATE TABLE  to display the table definition. 

## REPAIR TABLE Method 

The REPAIR TABLE  method is only applicable to MyISAM , ARCHIVE , and CSV  tables. 

You can use REPAIR TABLE  if the table checking operation indicates that there is a corruption or that an upgrade is required. For example, to repair a MyISAM  table, use this statement: 

REPAIR TABLE t1; 

mysqlcheck --repair  provides command-line access to the REPAIR TABLE  statement. This can be a more convenient means of repairing tables because you can use the --databases  or --all- databases  option to repair all tables in specific databases or all databases, respectively: 

mysqlcheck --repair --databases db_name  ... mysqlcheck --repair --all-databases 

## 2.11.14 Copying MySQL Databases to Another Machine 

In cases where you need to transfer databases between different architectures, you can use mysqldump to create a file containing SQL statements. You can then transfer the file to the other machine and feed it as input to the mysql  client. 

Use mysqldump --help  to see what options are available. 

<img src='content_image/665412.jpg'>

## Note 

If GTIDs are in use on the server where you create the dump ( gtid_mode=ON ), by default, mysqldump  includes the contents of the gtid_executed  set in the dump to transfer these to the new machine. The results of this can vary depending on the MySQL Server versions involved. Check the description for mysqldump’s --set- gtid-purged  option to find what happens with the versions you are using, and how to change the behavior if the outcome of the default behavior is not suitable for your situation. 

The easiest (although not the fastest) way to move a database between two machines is to run the following commands on the machine on which the database is located: 

mysqladmin -h ’ other_hostname ’ create db_name mysqldump db_name  | mysql -h ’ other_hostname ’ db_name 

If you want to copy a database from a remote machine over a slow network, you can use these commands: 

mysqladmin create db_name mysqldump -h ’ other_hostname ’ --compress db_name  | mysql db_name 

