set_innodb.sh 804 Bytes
Newer Older
1 2 3 4 5
#!/bin/bash
if [ "$1" == '-f' ]
then
    echo "Forcing"
    MYSQLCMD='mysql -u root'
6
    DBNAME='endi'
7 8 9 10 11 12 13
else
    echo "Enter the mysql command line needed to have root access (default: 'mysql -u root')"
    read MYSQLCMD
    if [ "$MYSQLCMD" == '' ]
    then
        MYSQLCMD='mysql -u root'
    fi
14
    echo "Enter the database name (default : 'endi')"
15 16 17
    read DBNAME
    if [ "$DBNAME" == '' ]
    then
18
        DBNAME='endi'
19 20 21 22 23 24 25 26 27
    fi
fi

for table in `echo show tables | $MYSQLCMD $DBNAME | grep -v Tables_in_`; do
        TABLE_TYPE=`echo show create table $table | $MYSQLCMD $DBNAME | sed -e's/.*ENGINE=\([[:alnum:]\]\+\)[[:space:]].*/\1/'|grep -v 'Create Table'`
        if [ $TABLE_TYPE = "MyISAM" ] ; then
                echo "ALTER TABLE $table ENGINE = InnoDB" | $MYSQLCMD $DBNAME
        fi
done