我试图按照本教程来启用远程访问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

其他回答

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

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

像这样相加

[mysqld]
max_allowed_packet = 256M

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

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

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,但以下是Mac OS X 5.5版本my.cnf文件的可能位置(从这里取):

/etc/my.cnf /etc/mysql/my.cnf SYSCONFDIR / my.cnf $ MYSQL_HOME / my.cnf Defaults-extra-file(使用——Defaults-extra-file =path指定的文件,如果有的话) ~ / .my.cnf