我试图按照本教程来启用远程访问MySQL。问题是,my.cnf文件应该放在哪里?我使用的是Mac OS X Lion。


当前回答

将/usr/local/opt/mysql/support-files/my-default.cnf复制为/etc/my.cnf或/etc/mysql/my.cnf,然后重启mysql。

其他回答

你可以在任何你想要的目录下创建你的文件。创建完成后,你可以“告诉”mysql配置的路径:

In my case, the file did not exist. In MySQL Workbench I went to OPTIONS FILE and found some default values. I clicked apply. It asked for permission. It then created the my.cnf file under /etc. However, it is very important to keep in mind that the first time you click "apply", you do not make any changes to the default configuration. Once the file has been created, you can make changes which will be applied when you click "apply". Otherwise you will not be shown the apply button when you make changes.

MySQL 5.7.18版本后,在support-files目录下不再提供默认配置文件。 因此,您可以在MySQL读取的位置手动创建my.cnf文件,例如/etc/mysql/my.cnf,并在该文件中添加您想要添加的配置。

我正在运行MacOS Mojave(10.14.6),为了让MySQL识别我的配置文件,我必须将它放在/usr/local/ MySQL -5.7.26-macos10.14-x86_64/etc/my.cnf中。我也有一个符号链接指向它从/usr/local/@mysql/etc/my.cnf。

我试图关闭sql_mode=only_full_group_by,在配置文件中设置该选项是在会话之间保持该设置的唯一方法。配置文件的内容如下:

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION

我正在使用MySQL的本机安装,而不是Homebrew设置。

macOS High Sierra 版本10.13.6

mysql Ver 14.14 Distrib 5.7.22,用于osx10.13 (x86_64)使用EditLine包装器 版权所有(c) 2000,2018, Oracle和/或其关联公司。版权所有

默认选项按给定顺序从以下文件中读取:

/etc/my.cnf 
/etc/mysql/my.cnf 
/usr/local/etc/my.cnf 
~/.my.cnf