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


当前回答

由于mysql——help显示了一个文件列表,我发现将结果管道到ls来查看它们中的哪些存在是有用的:

$ mysql --help | grep /my.cnf | xargs ls
ls: /etc/my.cnf: No such file or directory
ls: /etc/mysql/my.cnf: No such file or directory
ls: ~/.my.cnf: No such file or directory
/usr/local/etc/my.cnf

对于我的(安装了Homebrew) MySQL 5.7,文件似乎在/usr/local/etc/my.cnf.

其他回答

run

Sudo查找/ -name my.cnf

通常第一个结果是正确的。 应该在

/ usr / local / etc /

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

$ps aux | grep mysqld /usr/local/opt/mysql/bin/mysqld——basedir=/usr/local/opt/mysql——datadir=/usr/local/var/mysql——plugin-dir=/usr/local/opt/mysql/lib/plugin 放下你的我。Cf文件到/usr/local/opt/mysql 重启mysql

在shell上输入my_print_defaults——help

在结果的底部,您应该能够看到服务器从中读取配置的文件。它输出如下内容:

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

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

/opt/homebrew/etc/my.cnf

也可以通过mysql——help找到