【问题标题】:change mysql default engine to innodb将mysql默认引擎更改为innodb
【发布时间】:2011-01-21 23:35:02
【问题描述】:

我使用的是 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 成为默认存储引擎。我需要做什么?

【问题讨论】:

    标签: mysql


    【解决方案1】:

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

    default-storage-engine = innodb
    

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

    来自docs

    在 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
    

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

    【讨论】:

    • 我的ini文件在哪里。我如何找到 mysql 将在哪里查找 ini 文件。
    • 知道了。 /etc/my.cnf 工作,因为我得到 mysql: unknown variable 'default-storage-engine=innodb'
    • @Nadal:你把它放在[mysqld]下面了吗?
    • 在 mac 中也在 /etc/my.cnf 下。谢谢它的帮助。
    • 还建议使用innodb_file_per_table,这样数据库中的每个 InnoDB 表都有自己的.ibd 文件,而不是存储在单一的ibdata1 文件中。请参阅 dba.stackexchange.com/questions/15906/… 作为起始参考。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2014-02-26
      • 1970-01-01
      • 2013-04-25
      • 2011-05-11
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 2010-11-12
      相关资源
      最近更新 更多