网上的脚本搞得太复杂,自己写一个能用的.
!/bin/bash
author by lifh; in 20191206
DBLIST="test adwords_api_test" #转换的数据库,多个用空格隔开
USER="root" # 服务器信息
PASSWORD="XXXXXX"
HOST="192.168.11.121"
MYSQL_BIN="/usr/local/mysql/bin"
ENGINE_NAME="InnoDB"
for DB in {DB}"
HOST -uPASSWORD -e "select table_name from information_schema.TABLES where TABLE_SCHEMA='{DB}_table.txt
for table_name in cat /tmp/convert_${DB}_table.txt
do
echo "现在转换表 MYSQL_BIN/mysql -hUSER -pDB -e "alter table {ENGINE_NAME}'"
if [ {table_name} 转换成功"
else
echo "${table_name} 转换失败"
fi
done
done