It looks like MySQL has a way for table compression to be enabled, for InnoDB. However I don't care to modify the long term schema. I just need a one time compress of all tables in the db.
Is there a way to do this via query, otherwise a command line solution would be the next best thing.
I think there is confusion about the term "compress".
InnoDB has ROW_FORMAT=COMPRESSED
, which permanently writes the table in a different format. This makes the table about half the physical size.
OPTIMIZE TABLE
rebuilds the table, possibly 'defragmenting' and squeezing out some of the wasted space. This is rarely useful because the table will promptly grow again as you INSERT
/UPDATE
.
Each of those acts on a single table at a time.
What is your 'real' objective?