繁体   English   中英

将 mysql 默认引擎更改为 innodb

[英]change mysql default engine to innodb

我使用的是 mac,我使用自制软件安装了 mysql。

brew install mysql

非常标准的安装。

mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                    | Transactions | XA   | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                         | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance     | NO           | NO   | NO         |
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
+------------+---------+------------------------------------------------------------+--------------+------+------------+

我希望 innodb 成为默认的存储引擎。 我需要做什么?

在 ini 文件的[mysqld]部分下,添加:

default-storage-engine = innodb

它通常是/etc/my.cnf ,但不确定 Mac。

文档

在 Unix、Linux 和 Mac OS X 上,MySQL 程序按照指定的顺序从以下文件中读取启动选项(首先使用顶部项目)。

 File Name Purpose /etc/my.cnf Global options /etc/mysql/my.cnf Global options (as of MySQL 5.1.15) SYSCONFDIR/my.cnf Global options $MYSQL_HOME/my.cnf Server-specific options defaults-extra-file The file specified with --defaults-extra-file=path, if any ~/.my.cnf User-specific options

守护进程从不使用最后一个。

我可以从 phpMyAdmin 看到 MySQL 有一个名为information_schema的数据库,它包含一个名为ENGINES的表。 除了更改 ini 文件的更全局方案之外,切换MyISAMInnoDB表的SUPPORT字段(分别为“YES”和“DEFAULT”)难道不是一个简单的解决方案吗? 我自己没有做过,所以请自行承担风险……如果你这样做了,请告诉我结果如何。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM