I have this version of MySQL server:

mysql  Ver 8.0.15 for Linux on x86_64 (MySQL Community Server - GPL)

I use a some large tables. When I truncate database with truncate database <name>, I check the hard disk space and I've noticed my disk space is not reclaimed.

This is more information on my server:

SHOW VARIABLES LIKE 'innodb_file_per_table';
'innodb_file_per_table', 'ON'`

Any idea to resolve this ?

  • 1
    How large was this table? Was file_per_table set to ON when the table was created?
    – Rick James
    Oct 5, 2019 at 0:09

1 Answer 1

  1. You need to "reorganize/rebuild" the table truncated which can be achieved by below.

    mysql> OPTIMIZE table table_name;

for InnoDB tables, it run under ALTER operation.

reference: https://dev.mysql.com/doc/refman/8.0/en/optimize-table.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.