myisam引擎自动转换为innodb引擎脚本
时间:2010-08-10 来源:huangxifeng607
#!/bin/bash
#creator:hxf
#
if [ -z $1 ]
then
echo "usage:`basename $0` mysql dbname";
exit 14;
fi
mbin=${mbin:-/usr/bin/mysql};
db=$1;
rm -f /tmp/convert_engine.tmp;
# mbin=/usr/bin/mysql
$mbin -e "select concat('alter table "$db".',table_name,' engine=innodb;') from information_schema.tables where TABLE_SCHEMA='"$db"' and engine='MYISAM' into outfile '/tmp/convert_engine.tmp'";
$mbin < /tmp/convert_engine.tmp;
#creator:hxf
#
if [ -z $1 ]
then
echo "usage:`basename $0` mysql dbname";
exit 14;
fi
mbin=${mbin:-/usr/bin/mysql};
db=$1;
rm -f /tmp/convert_engine.tmp;
# mbin=/usr/bin/mysql
$mbin -e "select concat('alter table "$db".',table_name,' engine=innodb;') from information_schema.tables where TABLE_SCHEMA='"$db"' and engine='MYISAM' into outfile '/tmp/convert_engine.tmp'";
$mbin < /tmp/convert_engine.tmp;
相关阅读 更多 +