Script de convercao MySQL tabelas MyISAM para InnoDB

#!/bin/bash
# Script de convercao MySQL tabelas MyISAM para InnoDB
 
echo "Entre com o usuario MySQL"
read MYSQL_USER
 
echo "Entre com o password MySQL"
stty -echo
read MYSQL_PASSWD
stty echo
 
DATABASES=`mysql -u $MYSQL_USER -p$MYSQL_PASSWD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
 
for i in ${DATABASES[*]}; do
  if [ $i != 'mysql' ] && [ $i != 'information_schema' ] && [ $i != 'performance_schema' ]; then
    echo $( date +%H:%M) database: $i
    time mysql -u $MYSQL_USER $i -p$MYSQL_PASSWD -e "SHOW TABLE STATUS WHERE Engine='MyISAM';" | awk 'NR>1 {print "ALTER TABLE `"$1"` ENGINE = InnoDB;"}' | mysql -u $MYSQL_USER $i -p$MYSQL_PASSWD
  fi
  echo 
done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s