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


当前回答

在Mac OS X Maverick的情况下,当MySQL通过Homebrew安装时,它位于/usr/local/opt/mysql/my.cnf

其他回答

您可以打开一个终端并键入locate 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.

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文件

我在macOS High Sierra 10.13.3版本中使用mysql 5.7.17版本,我在这里找到了mysql配置文件。

cd /usr/local/mysql/support-files/my-default.cnf

如果你使用的是macOS Sierra,而该文件不存在, 运行

Mysql——help或Mysql——help | grep my.cnf

要查看mysql my.cnf的可能位置和加载/读取顺序,请在建议的目录之一中创建my.cnf文件,然后添加以下行

[mysqld] sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

您可以sudo触摸/{首选路径}/my.cnf,然后编辑文件添加sql模式by

Sudo nano /{首选路径}/my.cnf

然后重新启动MySQL。