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


当前回答

如果你使用的是macOS Sierra,而该文件不存在, 运行

Mysql——help或Mysql——help | grep my.cnf

要查看mysql my.cnf的可能位置和加载/读取顺序,请在建议的目录之一中创建my.cnf文件,然后添加以下行

[mysqld] sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

您可以sudo触摸/{首选路径}/my.cnf,然后编辑文件添加sql模式by

Sudo nano /{首选路径}/my.cnf

然后重新启动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 8.0.19,我终于找到my.cnf在这里: /usr/local/opt/mysql/.bottle/etc 我把它复制到 /usr/local/opt/mysql/ 并进行了修改。然后我重新启动mysql服务,它工作。

与所有这些伟大的答案相反。如果你在一个没有sudo权限的环境中工作。你的Homebrew可以安装在你的主目录下~如果是这种情况,你的mysql已经通过brew安装,安装mysql你的my.cnf可以位于~/ Homebrew /etc/my.cnf或者你也可以在你的home目录中查找。/ name 'my.cnf'

在MAC OS上,一个快速的方法是:

sudo find /usr/ -type f -iname "*my.cnf*"

or

brew list mysql@5.7 |grep -i 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设置。