Skip to content

Instantly share code, notes, and snippets.

@jonathanvx
Created May 21, 2012 14:24
Show Gist options
  • Save jonathanvx/2762572 to your computer and use it in GitHub Desktop.
Save jonathanvx/2762572 to your computer and use it in GitHub Desktop.
Burst Convert all tables to InnoDB
#!/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