My Question is actually very similar to this one and also includes a good answer for a case with InnoDB Engine tables:
I have noticed that drop schema do not shrink ibdata files , so i have looked for a methods to configure the DB so that the size will be reduced after deleting a schema.
i have found many links talking about InnoDB and the way to save table per file so that the .frm file it self will contain the table data and it will be reduced.
But what happens with MyISAM tables (with more than 5G table size).
ibdata1 and MyISAM are mutually exclusive.
First thing you should do is count how many tables use both storage engines:
If SOME tables are InnoDB:
Perform my CleanUp of InnoDB
If you have only MyISAM tables and no InnoDB tables:
First, eliminate any traces of InnoDB
Do the following:
STEP01) Add this to my.cnf
STEP02)
service mysql restartSTEP03)
rm -f /var/lib/mysql/ibdata1 /var/lib/mysql/ib_logfile*After these steps, you can perform a Compression of Each MyISAM tables like this:
For the table mydb.mytable that is MyISAM, just run one of the following:
OPTIMIZE TABLE mydb.mytable;ALTER TABLE mydb.mytable ENGINE=MyISAM; ANALYZE TABLE mydb.mytable;If you want to defrag all your MyISAM tables, here is a shell script to do so…
Once you trust the script visually, just run it
Give it a Try !!!
UPDATE 2012-07-25 09:52 EDT
I would like to clarify one of my suggestions for compression of MyISAM
I said earlier
OPTIMIZE TABLE mydb.mytable;ALTER TABLE mydb.mytable ENGINE=MyISAM; ANALYZE TABLE mydb.mytable;These commands are mechanically identical.
OPTIMIZE TABLEperforms a defrag of the MyISAM table and then runsANALYZE TABLEto compute fresh index statistics.Mechanically speaking, this is what
ALTER TABLE mydb.mytable ENGINE=MyISAM;does: