【问题标题】:Change default mysql storage engine using ~/.my.cnf使用 ~/.my.cnf 更改默认 mysql 存储引擎
【发布时间】:2014-12-12 19:04:27
【问题描述】:

我正在使用 MySQL 5.5 并尝试仅为我自己更改默认存储引擎。我尝试按照我在此处找到的说明在我的主目录中创建一个 .my.cnf 文件:

http://dev.mysql.com/doc/refman/5.5/en/storage-engine-setting.html

http://dev.mysql.com/doc/refman/5.5/en/option-files.html

你可以在这里看到我到目前为止所做的更改:

selah@selah-OptiPlex-9020:~$ cat .my.cnf
[mysqld]
default-storage-engine=MyISAM
selah@selah-OptiPlex-9020:~$ sudo /etc/init.d/mysql restart
[sudo] password for selah: 
 * Stopping MySQL database server mysqld                                                                                                  [ OK ] 
 * Starting MySQL database server mysqld                                                                                                  [ OK ] 
 * Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly.

但是 MyISAM 仍然不是默认的!

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

如何让它工作?

编辑:为了记录,我只是能够通过编辑我的 /etc/mysql/my.cnf 文件并重新启动我的计算机(只是重新启动进程失败)来完成这项工作。但是我仍然想了解如何仅为我的用户更改此设置!

【问题讨论】:

  • InnoDB 是一个很好的默认值。您有哪些要求使 MyISAM 成为必要?相比之下,这是一个糟糕的引擎。

标签: mysql myisam my.cnf


【解决方案1】:

default_storage_engine 是服务器设置,而不是连接设置。 mysqld 服务器不会读取你的用户 '~/.my.cnf',客户端只会读取 [client] 部分,而不是 [mysqld] 部分。

您可以通过 '~/.my.cnf' 中 [client] 部分中的 init-commend 更改它:

init-command="SET default_storage_engine=MYISAM;"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-05
    • 2011-06-05
    • 1970-01-01
    • 2011-03-04
    • 2019-01-14
    • 1970-01-01
    • 1970-01-01
    • 2021-05-29
    相关资源
    最近更新 更多