Mysql – How to compact thesql database size

MySQL

My folder mysql/data is huge. I have dropped some databases that have a huge amount of records, removed some logs tables but.. mysql/data size remains unchanged.

What is the best way to compact it? It takes something like 20 Gigabytes on HD and contains about 30 medium or small database. My whole databases folder takes 300 Megabytes.

In addition ibdata1, mysql-bin.000332, mysql-bin.000326, mysql-bin.000206 take about 20 Gigabytes.

PS: I use Windows 7

Best Answer

If all tables in your database uses InnoDB then fire Optimize table table_name ....make sure

"if your table size is 100MB then double of this size must be available in datadir drive.."

If you are using MyISAM you can check with MyISAMcheck utility to optimize myisam tables...

Which MySQL version you are using? If your MySQL DB version is 5.6 or 5.7 then ibtemp will be there in datadir. Normally MySQL not able purge all temporary tables which is created by user stored in ibtemp and it grows day by day. If you are affordable downtime then take restart of MySQL service. It free disk space used by ibtemp temporary Tablespace.

Read about innodb row format you will get idea..