Script to convert MySQL from InnoDB to MyISAM

May 11, 2015

If you need to convert all the MySQL tables in a database from InnoDB to MyISAM here is a handy script to automate the process for you.

[bash]
#!/bin/bash

DB=’your_database_name’
USER=’your_db_user’
PASS=’your_db_pass’

TABLES=$(mysql -p$PASS -u $USER –skip-column-names -B -D $DB -e ‘show tables’)
for T in $TABLES
do
mysql -p$PASS -u $USER -D $DB -e "ALTER TABLE $T ENGINE=MYISAM"
done
[/bash]

Leave a Reply

Your email address will not be published. Required fields are marked *