对于自制mysql安装,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

其他回答

在shell上输入my_print_defaults——help

在结果的底部,您应该能够看到服务器从中读取配置的文件。它输出如下内容:

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

由于mysql——help显示了一个文件列表,我发现将结果管道到ls来查看它们中的哪些存在是有用的:

$ mysql --help | grep /my.cnf | xargs ls
ls: /etc/my.cnf: No such file or directory
ls: /etc/mysql/my.cnf: No such file or directory
ls: ~/.my.cnf: No such file or directory
/usr/local/etc/my.cnf

对于我的(安装了Homebrew) MySQL 5.7,文件似乎在/usr/local/etc/my.cnf.

有一种方法可以知道:

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

对于MacOS (High Sierra),已经安装了自制的MySQL。

从mysql环境中增加全局变量不成功。因此,在这种情况下,创建~/.my.cnf是最安全的选择。使用[mysqld]添加变量将包括更改(注意:如果使用[mysql]更改,更改可能不起作用)。

<~/.my.cnf> [mysqld] connect_timeout = 43200 max_allowed_packet = 2048M net_buffer_length = 512M

重新启动mysql服务器。检查变量。 y

SELECT @@max_allowed_packet; +----------------------+ | @@max_allowed_packet | . +----------------------+ | 1073741824 | +----------------------+

set中的1行(0.00秒)

$ps aux | grep mysqld /usr/local/opt/mysql/bin/mysqld——basedir=/usr/local/opt/mysql——datadir=/usr/local/var/mysql——plugin-dir=/usr/local/opt/mysql/lib/plugin 放下你的我。Cf文件到/usr/local/opt/mysql 重启mysql