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


当前回答

您可以检查文件

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

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

其他回答

您可以打开一个终端并键入locate my.cnf

MySQL论坛上的这个帖子说:

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

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

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

打开连接 在菜单中选择“实例”下的“选项文件”。 MySQLWorkbench将搜索my.cnf,如果找不到它,它将为您创建它

将/usr/local/opt/mysql/support-files/my-default.cnf复制为/etc/my.cnf或/etc/mysql/my.cnf,然后重启mysql。

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,对我有用的是在我的~路径中创建一个.my.cnf文件。希望这能有所帮助。