将 mysql 默认引擎更改为 innodb

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4764974/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:25:44  来源:igfitidea点击:

change mysql default engine to innodb

mysql

提问by Nick Vanderbilt

I am using mac and I installed mysql using homebrew.

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

brew install mysql

pretty standard installation.

非常标准的安装。

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         |
+------------+---------+------------------------------------------------------------+--------------+------+------------+

I would like innodb to be the default storage engine. What do I need to do?

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

回答by Quassnoi

Under [mysqld]section in your ini file, add:

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

default-storage-engine = innodb

It is usually /etc/my.cnf, but not sure about Mac.

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

From the docs:

文档

On Unix, Linux and Mac OS X, MySQL programs read startup options from the following files, in the specified order (top items are used first).

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

在 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

The last one is never used by the daemon.

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

回答by KiloVoltaire

I can see from phpMyAdmin that MySQL has a database called information_schema, and it contains a table called ENGINES. Aside from the more global scenario of changing an ini file, wouldn't it be a simple solution to switch the table's SUPPORTfields for MyISAMand InnoDB(to 'YES' and 'DEFAULT' respectively)? I haven't done it myself, so proceed at your own risk ... and let me know how things turn out if you do.

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