This will convert every InnoDB table in database dbname to MyISAM
CONVERT_SCRIPT=Convert_dbname_InnoDB_to_MyISAM.sql
mysql -u... -p... -AN -e"SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' ENGINE=MyISAM;') FROM information_schema.tables WHERE table_schema='dbname' AND engine='InnoDB';" > ${CONVERT_SCRIPT}
mysql -u... -p... -A < ${CONVERT_SCRIPT}
This will convert every InnoDB table to MyISAM
CONVERT_SCRIPT=Convert_InnoDB_to_MyISAM.sql
mysql -u... -p... -AN -e"SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' ENGINE=MyISAM;') FROM information_schema.tables WHERE engine ='InnoDB';" > ${CONVERT_SCRIPT}
mysql -u... -p... -A < ${CONVERT_SCRIPT}
If you do not want the conversion of the tables to be replicated to Slaves, just put SET SQL_LOG_BIN=0; as the first line. That way, you can test the conversion in a Master/Slave setup by converting only the Slave first and then the Master later.
This will convert every InnoDB table in database dbname to MyISAM and not replicate to other servers
CONVERT_SCRIPT=Convert_dbname_InnoDB_to_MyISAM.sql
echo "SET SQL_LOG_BIN=0;" > ${CONVERT_SCRIPT}
mysql -u... -p... -AN -e"SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' ENGINE=MyISAM;') FROM information_schema.tables WHERE table_schema='dbname' AND engine='InnoDB';" >> ${CONVERT_SCRIPT}
mysql -u... -p... -A < ${CONVERT_SCRIPT}
This will convert every InnoDB table to MyISAM and not replicate to other servers
CONVERT_SCRIPT=Convert_InnoDB_to_MyISAM.sql
echo "SET SQL_LOG_BIN=0;" > ${CONVERT_SCRIPT}
mysql -u... -p... -AN -e"SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' ENGINE=MyISAM;') FROM information_schema.tables WHERE engine ='InnoDB';" >> ${CONVERT_SCRIPT}
mysql -u... -p... -A < ${CONVERT_SCRIPT}
I'm not aware of any way to do this in mysql itself, but a simple shell script will do the job:
You can use MySQL to script it and execute it:
This will convert every InnoDB table in database
dbname
to MyISAMThis will convert every InnoDB table to MyISAM
If you do not want the conversion of the tables to be replicated to Slaves, just put
SET SQL_LOG_BIN=0;
as the first line. That way, you can test the conversion in a Master/Slave setup by converting only the Slave first and then the Master later.This will convert every InnoDB table in database
dbname
to MyISAM and not replicate to other serversThis will convert every InnoDB table to MyISAM and not replicate to other servers
Give it a Try !!!
For those who still having this issue, you can follow this way to do it, I found this answer in a website. It helps me a lot:
shell> mysql -u username -p -e "SELECT concat('ALTER TABLE ', TABLE_NAME,' ENGINE=MYISAM;') FROM Information_schema.TABLES WHERE TABLE_SCHEMA = 'db_name' AND ENGINE = 'InnoDB' AND TABLE_TYPE = 'BASE TABLE'" | tail -n+2 >> alter.sql
Update
username
anddb_name
values with your own values.Afet executing the script, it will save a file under name:
alter.sql
Open the file and execute the content on yourphpmyadmin
ormysql
command line.Cheers!
I prefer one-liners for this type of stuff. This is a one-liner version of the most accepted answer.
This works if you have your MySQL username and password set in
~/.my.cnf
.