Mysql更改引擎
作者:linux120 发布时间:May 12, 2014 分类:服务器维护
务必在操作之前先备份数据!!!!!!看看这六个感叹号就知道有多重要了。
Innodb -> Myisam:
mysql -u username -p -e "SELECT concat('ALTER TABLE ', TABLE_NAME,' ENGINE=MYISAM;') FROM Information_schema.TABLES WHERE TABLE_SCHEMA = 'db_name' AND ENGINE = 'InnoDB' AND TABLE_TYPE = 'BASE TABLE'" | tail -n+2 >> alter.sql
然后导入alter.sql即可。
Myisam -> Innodb:
一个库中的所有表:
mysql -e "SELECT concat('ALTER TABLE ',TABLE_NAME,' DROP INDEX ', index_name, ' ;')
FROM information_Schema.STATISTICS
WHERE table_schema = 'db_wordpress'
AND index_type = 'FULLTEXT' ORDER BY index_name " | tail -n+2 > drop.sql
所有库的所有表:
mysql -e "SELECT concat('ALTER TABLE \`',TABLE_SCHEMA,'\`.',TABLE_NAME,' DROP INDEX ', index_name, ' ;')
FROM information_Schema.STATISTICS
WHERE TABLE_SCHEMA != 'mysql'
AND index_type = 'FULLTEXT' ORDER BY index_name " | tail -n+2 > drop.sql
评论已关闭