mysql - 将mysql默认引擎更改为innodb

标签 mysql

我使用的是 mac,我使用 homebrew 安装了 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就不确定了。

来自 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

最后一个永远不会被守护进程使用。

关于mysql - 将mysql默认引擎更改为innodb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4764974/

相关文章:

php - 更新行直到总和匹配?

mysql - 从 SQL Server(ODBC 连接)使用 MySQL 作为链接服务器时查询缓慢

主键条件缓慢的 MySQL 更新

mysql - 如何让 friend 的 friend 的 friend ...

java - 定位Java/mySQL应用的瓶颈

MySQL 每场比赛只选择 1 个

php - 将 HTML 表数据添加到 MySQL 数据库中

php - OOPHP 在函数内调用函数

mysql - 在某个日期之间为 id_emp 选择计数 id_product

mysql - 存储对 MYSQL 数据库所做的更改并将更改更新到不同服务器上的另一个 MYSQL 数据库