数据库
首页 > 数据库> > mysql – 如何将innodb引擎表转换为tokudb引擎

mysql – 如何将innodb引擎表转换为tokudb引擎

作者:互联网

嗨,我想迁移我的服务器新安装的tokudb引擎.我想将每个数据库表从innodb转换为tokudb.我怎么能用sed命令呢?

解决方法:

而不是使用sed,为什么不让mysql为你编写转换脚本?

echo "SET SQL_LOG_BIN = 0;" > Convert_InnoDB_to_TokuDB.sql
MYSQL_USER=root
MYSQL_PASS=password
MYSQL_USERPASS="-u${MYSQL_USER} -p${MYSQL_PASS}"
MYSQL_PORT=3306
MYSQL_CONN="-h127.0.0.1 -P${MYSQL_PORT} ${MYSQL_USERPASS}"
SQLSTMT="SELECT CONCAT('ALTER TABLE ',table_schema,'.',"
SQLSTMT="${SQLSTMT} table_name,' ENGINE=TokuDB;') InnoDBConversionSQL"
SQLSTMT="${SQLSTMT} FROM information_schema.tables WHERE engine='InnoDB'"
SQLSTMT="${SQLSTMT} ORDER BY data_length"
MYSQL_OPTIONS="--skip-column-names -AN"
mysql ${MYSQL_CONN} ${MYSQL_OPTIONS} -e"${SQLSTMT}" >> Convert_InnoDB_to_TokuDB.sql
less Convert_InnoDB_to_TokuDB.sql

如果对转换脚本感到满意,请运行它

mysql ${MYSQL_CONN} ${MYSQL_OPTIONS} < Convert_InnoDB_to_TokuDB.sql

试试看 !!!

标签:mysql,innodb,tokudb,storage-engine
来源: https://codeday.me/bug/20190806/1602448.html