Skip to content

Instantly share code, notes, and snippets.

@0x00dec0de
Created October 15, 2015 13:29
Show Gist options
  • Save 0x00dec0de/48aea6889abb76e8c7ce to your computer and use it in GitHub Desktop.
Save 0x00dec0de/48aea6889abb76e8c7ce to your computer and use it in GitHub Desktop.
sch to inoddb
#!/bin/bash
TMPFILE=`mktemp tmp.XXXXXXXXX`
MYSQL=`which mysql`
PANEL=`hostname |cut -b3-4`
#echo $PANEL
if [ "$PANEL" = "wm" ]; then
MYPASS=`cat /root/mysql_passwd`
elif [ "$PANEL" = "da" ]; then
MYPASS=`grep mysql= /usr/local/directadmin/scripts/setup.txt | cut -d'=' -f 2`
fi
#echo $MYPASS
> $TMPFILE
echo "list database,table with myisam for 3 rot_* tables to $TMPFILE"
$MYSQL -p$MYPASS -e "SELECT TABLE_SCHEMA, table_name FROM INFORMATION_SCHEMA.TABLES where table_name LIKE 'rot_gal2group' and Engine = 'MyISAM'" | tail -n +2 >> $TMPFILE
$MYSQL -p$MYPASS -e "SELECT TABLE_SCHEMA, table_name FROM INFORMATION_SCHEMA.TABLES where table_name LIKE 'rot_gallery_stats' and Engine = 'MyISAM'" | tail -n +2 >> $TMPFILE
$MYSQL -p$MYPASS -e "SELECT TABLE_SCHEMA, table_name FROM INFORMATION_SCHEMA.TABLES where table_name LIKE 'rot_galleries' and Engine = 'MyISAM'" | tail -n +2 >> $TMPFILE
echo "converting tables to innodb"
cat $TMPFILE |while read l; do read -d, c1 c2 < <(echo $l) ; echo "$c1 $c2 "; $MYSQL -p$MYPASS -e "use $c1; alter table $c2 ENGINE = INNODB;" ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment