Mysql – Simpler way to convert all tables from InnoDB to MyISAM

innodbmyisamMySQL

Previously, I use this:

USE dbname;
ALTER TABLE tablename ENGINE=MYISAM;

I'm looking for simpler way to convert all tables in a database, rather than writing every table name one by one

Best Answer

I'm not aware of any way to do this in mysql itself, but a simple shell script will do the job:

TABLES=$(mysql -pXXXXXXX -uXXXXXXX --skip-column-names -B -D $DB -e 'show tables')
for T in $TABLES
do
    mysql -pXXXXX -uXXXXX -D $DB -e "ALTER TABLE $T ENGINE=MYISAM"
done