There are two ways to reorganize the physical storage of table data and associated index data to reduce storage space.
1. Use OPTIMIZE TABLE or MYSQLCHECK.
OPTIMIZE TABLE tb1_namebut optimize table can only be performed for one table, if you want to optimize all the databases, you could either write a script to do it or use mysqlcheck command instead.
MYSQLCHECK -o --all-databases
2. Resize the InnoDB Tablespace (if not use innodb_file_per_table?)
- use mysqldump to dump all the InnoDB tables, including InnoDB tables located in MySQL database.
- stop the server.
- remove all the existing tablespace files
(
*.ibd
), including theibdata
andib_log
files. Do not forget to remove*.ibd
files for tables located in the MySQL database. - remove any .frm files for InnoDB tables.
- configure a new tablespace.
- restart the server
- import the dump files.
InnoDB
engine,
it may be simpler to dump all
databases, stop the server, remove all databases and
InnoDB
log files, restart the server, and
import the dump files. References
No comments:
Post a Comment