Sometimes you encounter a server with multiple tables of a particular storage engine which you need to convert to another storage engine. For us, this often happens when we find systems running MyISAM and we want to get these over to InnoDB.
There are a number of reasons to consider converting a table to another storage engine, such as performance, gaining additional features such as Foreign Keys, and so on. You should, however, stop to consider that not all storage engines are created the same and do not offer the same features.
If there are hundreds of tables, the process can be very time consuming so we put together a simple bash script to automate this process.
#!/bin/sh MY_USER="root" MY_PASSWORD="mypassword" MY_HOST="127.0.0.1" MY_PORT=3306 NEW_ENGINE="InnoDB" TABLES=`mysql -u$MY_USER -p$MY_PASSWORD -h$MY_HOST -P$MY_PORT -e"SELECT CONCAT(TABLE_SCHEMA,'.',TABLE_NAME) AS 'TABLE' FROM …[Read more]