Convert mySQL engine from myISAM to InnoDB

This will output a list of Alter command that you can run in mySQL console

SET @DATABASE_NAME = 'database_name_to_convert';
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'MyISAM'
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;

This is a bash oneliner that will convert the Database, NOTE: you will have to type your password in twice, or change the -p for -p”password”

mysql -u root -p database_name_to_convert -e "show table status where Engine='MyISAM';" | awk 'NR>1 {print "ALTER TABLE "$1" ENGINE = InnoDB;"}' | mysql -u root -p database_name_to_convert