对于自制mysql安装,my.cnf在哪里?它安装了吗?


当前回答

在我的系统里是这样的

nano /usr/local/etc/my.cnf.default 

作为模板和

nano /usr/local/etc/my.cnf

为工作。

其他回答

有一种方法可以知道:

sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf

如果您使用的是mac m1 (Apple silicon), my.cnf位于

/opt/homebrew/etc/my.cnf

也可以通过mysql——help找到

我相信答案是否定的。在~/.my.cnf或/usr/local/etc中安装一个似乎是首选的解决方案。

对于MacOS (High Sierra),已经安装了自制的MySQL。

从mysql环境中增加全局变量不成功。因此,在这种情况下,创建~/.my.cnf是最安全的选择。使用[mysqld]添加变量将包括更改(注意:如果使用[mysql]更改,更改可能不起作用)。

<~/.my.cnf> [mysqld] connect_timeout = 43200 max_allowed_packet = 2048M net_buffer_length = 512M

重新启动mysql服务器。检查变量。 y

SELECT @@max_allowed_packet; +----------------------+ | @@max_allowed_packet | . +----------------------+ | 1073741824 | +----------------------+

set中的1行(0.00秒)

默认情况下没有my.cnf。因此,MySQL以所有默认设置启动。如果您想创建自己的my.cnf来覆盖任何默认值,请将其放在/etc/my.cnf

同样,你也可以运行mysql——help来查找上面列出的conf位置。

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

正如你所看到的,还有一些选项可以绕过conf文件,或者当你在命令行上调用mysql时指定要读取的其他文件。