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


当前回答

我不知道你使用的是哪个版本的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

其他回答

/private/etc/my.cnf for Catalina

在Mac OS X Maverick的情况下,当MySQL通过Homebrew安装时,它位于/usr/local/opt/mysql/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

MySQL论坛上的这个帖子说:

默认情况下,OS X安装不使用my.cnf, MySQL只使用默认值。要设置你自己的my.cnf,你可以直接在/etc中创建一个文件。

OS X在/usr/local/mysql/support-files/目录下提供了配置文件示例。

如果你在那里找不到它们,MySQLWorkbench可以为你创建它们:

打开连接 在菜单中选择“实例”下的“选项文件”。 MySQLWorkbench将搜索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.