Mysql数据库 存储引擎 MyISAM转InnoDB 批量脚本

 
 
本文提供了将 Mysql MyISAM 存储引擎转为InnoDB存储引擎的shell脚本,代码如下:
 
 
#!/bin/bash
MUSER="root";
MPASS=$(cat /data/soft/mysql_root);
MSOCKET="/tmp/mysql.sock";

sql="select table_name from information_schema.tables where table_schema not in ('information_schema', 'mysql') and engine ='MyISAM';"
tablelist=`/opt/server/mysql/bin/mysql --socket=$MSOCKET -u$MUSER -p$MPASS -e"$sql"`

for i in ${tablelist[@]}
do
if [[ "$i" != "table_name" ]]
then
/usr/local/mysql/bin/mysql -u${MUSER} -p${MPASS} --socket=${MSOCKET} -e "ALTER TABLE bp2_yaccount.${i} ENGINE=InnoDB";
sleep 2
fi

done

0 个评论

要回复文章请先登录注册