Skip to content

Instantly share code, notes, and snippets.

@temoto
Last active March 15, 2016 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temoto/0184d37cac266c9de674 to your computer and use it in GitHub Desktop.
Save temoto/0184d37cac266c9de674 to your computer and use it in GitHub Desktop.
MySQL administration: convert MyISAM tables to InnoDB
#!/bin/bash
sql_list="select table_schema, table_name from information_schema.tables where lower(engine) = 'myisam' and table_schema not in ('mysql', 'information_schema', 'performance_schema') order by data_length;"
mysql --batch --silent -e "$sql_list" |while read -r d t; do
printf "\n---\n$d.$t "
mysql --batch --silent -e "select (data_length+index_length)/1e6 from information_schema.tables where table_schema='$d' and table_name='$t';"
time mysql --batch --silent -e "alter table $d.$t engine='innodb';"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment