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


当前回答

我在macOS Sierra上安装了MySql 5.7.12

支持文件位于

/usr/local/opt/mysql/support-files

只要将my-default.cnf复制到/etc/my.cnf或/etc/mysql/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.

您可以检查文件

/usr/local/bin/mysql.服务器,看看my.conf是从哪里读取的。

通常是从/etc/my.cnf或~/my.cnf或~/.my.cnf

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

/private/etc/my.cnf for Catalina

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