Last active
March 15, 2016 10:57
-
-
Save temoto/0184d37cac266c9de674 to your computer and use it in GitHub Desktop.
MySQL administration: convert MyISAM tables to InnoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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