Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> MySQL

Cách thu gọn/ dọn dẹp file ibdata1 trong MySQL?


File ibdata1 (tablespace chung InnoDB) không thể shrink trực tiếp. Cách duy nhất: dump toàn bộ database, xóa file, reload.

Giải pháp: bật innodb_file_per_table

Mỗi bảng lưu riêng file .ibd (mặc định từ MySQL 5.6.6).

Cách thu gọn/ dọn dẹp file ibdata1 trong MySQL?

Nếu MySQL < 5.6.6, thêm vào my.cnf

[mysqld]
innodb_file_per_table = 1

Sau khi bật, các bảng mới tạo sẽ có file .ibd riêng, có thể reclaim'espace khi DROP/TRUNCATE TABLE.