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


当前回答

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

其他回答

它通常应该在MAC上的/usr/local/etc下,如果你找不到它,你可以创建一个

在mysql 5.6.22中,my.cnf的路径为

/usr/local/opt/mysql/my.cnf 

我正在运行MacOS Catalina(10.15.3),并在/usr/local/etc中找到my.cnf

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.

在Mac OS X Maverick的情况下,当MySQL通过Homebrew安装时,它位于/usr/local/opt/mysql/my.cnf