gpt4 book ai didi

mysql - 使用 ~/.my.cnf 更改默认 mysql 存储引擎

转载 作者:行者123 更新时间:2023-11-29 23:19:28 24 4
gpt4 key购买 nike

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

最佳答案

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

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

init-command="SET default_storage_engine=MYISAM;"

关于mysql - 使用 ~/.my.cnf 更改默认 mysql 存储引擎,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27450411/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com