Bug #67836 Resizing InnoDB system tablespace ibdata1
Submitted: 7 Dec 2012 8:59 Modified: 3 Jan 2013 8:09
Reporter: Oli Sennhauser Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S4 (Feature request)
Version:any OS:Any (any)
Assigned to: CPU Architecture:Any
Tags: innodb, system tablespace

[7 Dec 2012 8:59] Oli Sennhauser
Description:
Sometimes MySQL users have the situation that the InnoDB system tablespace ibdata grows very large without noticing (I have heard cases up to 1 TB). Theses databases are hard to impossible to dump and restore again into a different database. So physical methods are needed.

We would like to have a method to physically reorganize and shrink the system tablespace.

How to repeat:
We have a PoC that this basically works:

mysql_upgrade --optimize --all-databases --> all tables are moved to their own tablespaces
resize the ibdata with dd
change the expected number of blocks and the old and new checksum in the header of the ibdata with a hexeditor (block #0).

Then the database seems to work after a restart.

We are aware that this is very evil and thus should be supported by the software vendor.

Suggested fix:
ALTER DATABASE REORGANIZE DATA_DICTIONARY;
ALTER DATABASE DATAFILE 'file_name' SIZE 1G;
ALTER DATABASE DROP DATAFILE 'file_name';
[22 Dec 2012 11:16] MySQL Verification Team
is this a duplicate of http://bugs.mysql.com/bug.php?id=1341 ?
how the final solution could be implemented might vary, but the problem is same.