0

我正在使用 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 文件并重新启动我的计算机(只是重新启动进程失败)来完成这项工作。但是,我仍然想了解如何仅为我的用户更改此设置!

4

1 回答 1

0

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

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

init-command="SET default_storage_engine=MYISAM;"
于 2014-12-12T20:02:21.077 回答