对于自制mysql安装,my.cnf在哪里?它安装了吗?


当前回答

run

Sudo查找/ -name my.cnf

通常第一个结果是正确的。 应该在

/ usr / local / etc /

其他回答

在Homebrew的情况下,mysql也会在它的Cellar目录中查找my.cnf,例如:

/usr/local/Cellar/mysql/5.7.21/my.cnf

对于这种情况,人们更喜欢将配置文件保持在接近二进制文件的位置——如果缺少的话,在这里创建my.cnf。

修改后重启mysql:

brew services restart mysql

run

Sudo查找/ -name my.cnf

通常第一个结果是正确的。 应该在

/ usr / local / etc /

我相信答案是否定的。在~/.my.cnf或/usr/local/etc中安装一个似乎是首选的解决方案。

有一种方法可以知道:

sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf

没有什么能真正帮到我——我无法覆盖/etc/my.cnf文件中的设置。 所以我搜索了约翰建议的https://stackoverflow.com/a/7974114/717251

sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf

它发现另一个my.cnf在

/usr/local/Cellar/mysql/5.6.21/my.cnf

更改这个文件对我有用!别忘了重启启动Agent:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

更新:

如果你最近安装了homebrew,你应该使用brew services命令重新启动mysql(使用你安装的homebrew mysql版本,即mysql或mysql@5.7):

brew services stop mysql
brew services start mysql