Tuesday 8 May 2012

Convert InnoDB TO MyISAM Script

Hi,

To convert InnoDB to MyISAM, you can use the following script. This is applicable for a single database. Stop Apache before doing this.

=======================
 #/bin/bash
#script to convert the whole database to myisam format.
cp -iRfp /var/lib/mysql /var/lib/mysql-$(date +%s)
for DATABASE_NAME in $(mysql --batch --column-names=false -e "show databases");
do
for t in $(mysql --batch --column-names=false -e "show tables" $DATABASE_NAME);
do
mysql -e "alter table $t type=MyIsam" $DATABASE_NAME;
echo "converted "$t" to MyIsam"
done
done 
========================

Thanks.

No comments:

Post a Comment