Created
May 21, 2012 14:24
-
-
Save jonathanvx/2762572 to your computer and use it in GitHub Desktop.
Burst Convert all 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 | |
MAX1=`mysql -e"select @@global.max_connections;" -N -B` | |
MAX=$[$MAX1 - 5] | |
echo "select table_name from information_schema.tables where engine='myisam' and table_schema='dbname' order by DATA_LENGTH desc limit $MAX;" | mysql --database=dbname -B -N | awk '{print "mysql dbname -e\"set sql_log_bin=0; ALTER TABLE", $1, "engine=innodb;\" &"}' > /tmp/massconvert.sh | |
bash /tmp/massconvert.sh | |
rm -f /tmp/massconvert.sh | |
echo "select table_name from information_schema.tables where engine='myisam' and table_schema='dbname' order by DATA_LENGTH desc limit $MAX,99999;" | mysql --database=dbname -B -N | awk '{print "set sql_log_bin=0; ALTER TABLE", $1, "engine=innodb;"}' | mysql --database=dbname -f & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment