Changing Settings for all MySQL tables
As part of my migration to MariaDB I wanted to change all the wordpress tables from MyISAM to INNODB. Of course you can do this one table at a time with alter table fred engine=innodb; Personally I prefer to automate where ever possible so I created the following linux shell script to convert all the tables in one database in one go
1DBNAME=”blog”
2DBUSER=”xxxx”
3DBPWD=”xxxxxxxx”
4for t in $(mysql -u$DBUSER -p$DBPWD –batch –column-names=false -e “show tables” $DBNAME);
5do
6echo “Converting table $t”
7mysql -u$DBUSER -p$DBPWD -e “alter table $t engine=innodb” $DBNAME;
8done
This script could of course be used for many things by just changing the SQL in line 7
comments powered by Disqus