简体   繁体   English

使用〜/ .my.cnf更改默认的mysql存储引擎

[英]Change default mysql storage engine using ~/.my.cnf

I am using MySQL 5.5 and trying to change they default storage engine for myself only. 我正在使用MySQL 5.5,并尝试仅为自己更改默认存储引擎。 I tried creating a .my.cnf file in my home directory as per instructions I found here: 我尝试按照在这里找到的说明在主目录中创建.my.cnf文件:

http://dev.mysql.com/doc/refman/5.5/en/storage-engine-setting.html 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 http://dev.mysql.com/doc/refman/5.5/en/option-files.html

You can see the changes I've made so far here: 您可以在这里看到我到目前为止所做的更改:

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.

However MyISAM is still not the default! 但是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)

How do I get this to work? 我该如何工作?

EDIT: For the record I was just able to get this working by editing my /etc/mysql/my.cnf file and restarting my COMPUTER (simply restarting the process failed). 编辑:记录下来,我只是可以通过编辑/etc/mysql/my.cnf文件并重新启动计算机(仅重新启动该过程失败)来使此工作正常。 However I would still like to understand how to change this for my user only! 但是,我仍然想了解如何仅为我的用户更改此设置!

default_storage_engine is a server setting, not a connection setting. default_storage_engine是服务器设置,而不是连接设置。 The mysqld server doesn't read your user '~/.my.cnf', and clients only read the [client] section, not the [mysqld] section. mysqld服务器不会读取您的用户“〜/ .my.cnf”,而客户端仅读取[client]部分,而不是[mysqld]部分。

You can change it via the init-commend in the [client] section in '~/.my.cnf' though: 您可以通过〜/ .my.cnf中[client]部分的init-commend commend更改它:

init-command="SET default_storage_engine=MYISAM;"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM