convert mysql table engine myisam to innodb


#!/bin/bash
if [ $# -ne 1 ]; then
  echo "usage: convert.sh  database"
  exit 1
fi
date
db=$1
echo  "Convert database $db" ;
mysql -B -N -e "SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '$db' and engine='myisam'"  |awk '{print $1}'| while read table; \
do \
     echo "+ Converting Table $table"; \
     mysql -B -N -e "alter table $table engine=innodb" $db; \
done;

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Protected by WP Anti Spam