'ALTER table' for all tables in a database

Assuming your have your credentials and connection information setup on your my.cnf a command like this may do what you want.

mysql --batch --skip-column-names --execute \
'select concat("alter table ",TABLE_SCHEMA,".",TABLE_NAME," type=innodb;") 
 from information_schema.TABLES where TABLE_SCHEMA="database_name"' | mysql

Replace database_name with your database name.

As for you main issue. It sounds like you want to reclaim space after letting your innodb tables get large. Like the bug said, the only safe way to deal with this is to use mysqldump to export everything. Delete the files and then restore.

As that article notes. You can enable innodb_file_per_table option to your server's my.cnf will make each file exist as a separate file. That way reclaiming space can be done by deleting/restoring the problem table instead of everything.


About Zoredache's answer (which has been very useful for me, thank you): --skip-column-names should be used to remove the headline.

mysql --batch --skip-column-names -e \ 
'select concat("alter table ",TABLE_SCHEMA,".",TABLE_NAME," type=innodb;")  
 from information_schema.TABLES where TABLE_SCHEMA="database_name"' | mysql