MySQL禁用InnoDB的真正方法

为什么突出“真正”呢?原因很简单,我去百度,谷歌搜索,搜出来的一大堆方法都是不靠谱的,做不到禁用,更会使你的MySQL服务器启动不起来。先来看看网上的办法,大致分为两步:一、设置默认的存储引擎为MyISAM;二、设置禁用InnoDB。

下面说说网上的配置代码,很简单,两句:

default-storage-engine = MyISAM
loose-skip-innodb
更有坑爹的是这样的:
default-storage-engine = MyISAM
skip-innodb
殊不知skip-innodb已经是很久以前的配置参数了,5.5/5.6以后就改成loose-skip-innodb了!可是网上还是有很多人照搬照抄别人的教程,也不去实践下,误人子弟。 其实上述两种方案都是不对的,配置后MySQL都是无法正常启动的,查看主要错误日志如下:
2017-03-21 22:39:40 18171 [Note] Plugin 'InnoDB' is disabled.
2017-03-21 22:39:40 18171 [Note] Plugin 'FEDERATED' is disabled.
2017-03-21 22:39:40 18171 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-03-21 22:39:40 18171 [ERROR] Aborting
根据这段错误日志,搜索到的还是很多错误的配置方法,直到我找到了官方的文档才解决,具体文档请戳:[http://docs.oracle.com/cd/E17952_01/refman-5.6-en/innodb-turning-off.html](http://docs.oracle.com/cd/E17952_01/refman-5.6-en/innodb-turning-off.html)。真正有效的禁用InnoDB的配置代码如下:
default-storage-engine = MyISAM
default-tmp-storage-engine = MYISAM
loose-skip-innodb
按照官方文档,仅上面配置的话MySQL可能会意外崩溃,我们需要加入更多配置禁用相关插件来防止其崩溃,所以完整的配置贴出来:
default-storage-engine = MyISAM
default-tmp-storage-engine = MYISAM
loose-skip-innodb

loose-innodb-trx = 0
loose-innodb-locks = 0
loose-innodb-lock-waits = 0
loose-innodb-cmp = 0
loose-innodb-cmp-per-index = 0
loose-innodb-cmp-per-index-reset = 0
loose-innodb-cmp-reset = 0
loose-innodb-cmpmem = 0
loose-innodb-cmpmem-reset = 0
loose-innodb-buffer-page = 0
loose-innodb-buffer-page-lru = 0
loose-innodb-buffer-pool-stats = 0
loose-innodb-metrics = 0
loose-innodb-ft-default-stopword = 0
loose-innodb-ft-deleted = 0
loose-innodb-ft-being-deleted = 0
loose-innodb-ft-config = 0
loose-innodb-ft-index-cache = 0
loose-innodb-ft-index-table = 0
loose-innodb-sys-tables = 0
loose-innodb-sys-tablestats = 0
loose-innodb-sys-indexes = 0
loose-innodb-sys-columns = 0
loose-innodb-sys-fields = 0
loose-innodb-sys-foreign = 0
loose-innodb-sys-foreign-cols = 0
OK,添加好之后再重启MySQL服务器,然后你就能看到InnoDB已经被彻底禁用了,至于怎么查看MySQL支持的引擎,简单的可以在phpMyAdmin里面查看,也可以通过命令行的形式查看。
show engines;
-------------本文结束感谢您的阅读-------------