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


当前回答

对于MAMP 3.5 Mac El Capitan,创建一个单独的空配置文件,并为mysql编写额外的设置

sudo vim /Applications/MAMP/Library/my.cnf

像这样相加

[mysqld]
max_allowed_packet = 256M

其他回答

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

Mac OS X Mavericks的当前MySQL包(在撰写本文时为MySQL -5.6.17-osx10.7-x86_64)在安装期间自动创建my.cnf。

它位于/usr/local/mysql-5.6.17-osx10.7-x86_64/my.cnf 根据您的版本调整路径。

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

MySQL 5.7 on Mac OS X El Capitan: /usr/local/mysql/etc/my.cnf

从/usr/local/mysql/support-files/my-default.cnf拷贝default conf文件