MySQL InnoDB Storage Engine Cleanup
In order to cleanse a MySQL InnoDB storage engine and remove data from deleted tables, follow these steps:
Understanding InnoDB Architecture
InnoDB stores six types of information in the ibdata1 file:
Can You Run OPTIMIZE TABLE?
Using OPTIMIZE TABLE on an InnoDB table stored in ibdata1 has two effects:
Can You Run OPTIMIZE TABLE with innodb_file_per_table?
With this option enabled, OPTIMIZE TABLE creates separate .ibd files for each InnoDB table. While this segregation separates data and indexes from ibdata1, it does not remove data dictionary entries from ibdata1.
InnoDB Infrastructure Cleanup
To shrink ibdata1 and remove unnecessary data:
Modify my.cnf (or my.ini) with these settings:
After this process, ibdata1 will contain only table metadata, and individual InnoDB tables will be stored in separate files with .frm and .ibd extensions. OPTIMIZE TABLE can then be used to shrink the table's .ibd file.
The above is the detailed content of How Can I Clean Up and Shrink My MySQL InnoDB Storage Engine?. For more information, please follow other related articles on the PHP Chinese website!