mysql转换表的存储引擎脚本

vi convert_tbale_engine.sh
#!/bin/bash
DB=test
USER=root
PASSWORD=123456
HOST=192.168.1.10
MySQL_BIN=/usr/local/bin
S_ENGINE=MyISAM
D_ENGINE=InnoDB
$MYSQL_BIN/mysql -h$HOST -u$USER -p$PASSWORD $DB -s -e "select table_name from infomation_schem.table where table_schema='test' and engine='myisam'"|grep -v "table_name" >table.txt
for t_name in `cat table.txt`
do 
echo "Staring convert table $t_name..."
sleep 1
$MYSQL_BIN/mysql -h$HOST -u$USER -p$PASSWORD $DB -e "alter table $t_name engine=$D_ENGINE"
if [ $? -eq 0 ];then
echo "Convert table $t_name ended ">con_table.log
sleep 1
else
echo "Convert tbale $t_name failed ">con_table.log
fi
done

文章题目:mysql转换表的存储引擎脚本
标题来源:http://csdahua.cn/article/pggocg.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流