Skip to content

Instantly share code, notes, and snippets.

@dplummer
Created March 20, 2011 19:32
Show Gist options
  • Save dplummer/878588 to your computer and use it in GitHub Desktop.
Save dplummer/878588 to your computer and use it in GitHub Desktop.
checking and altering table engines in mysql
# Find out what table engine your tables are using
select table_name, engine from information_schema.TABLES WHERE TABLE_SCHEMA = 'DATABASENAME';
# From bash, set the engine on all tables in a database to InnoDB
# Where /etc/mysql/debian.cnf has the root password for your mysql box
# Taken from http://kevin.vanzonneveld.net/techblog/article/convert_all_tables_to_innodb_in_one_go/
DATABASENAME="test"
for t in `echo "show tables" | mysql --defaults-file=/etc/mysql/debian.cnf --batch --skip-column-names $DATABASENAME`; do mysql --defaults-file=/etc/mysql/debian.cnf $DATABASENAME -e "ALTER TABLE $t ENGINE = InnoDB;"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment