brew mysql 添加修改mysql配置

brew安装的mysql是没有默认配置文件的,因此Mysql使用默认配置启动。我们需要手动创建my.cnf去覆盖默认配置。在/usr/local/opt/mysql 下确实有 my.cnf 但是并没有在启用中,应该是作为一个示例保存在安装目录的吧。所以手动添加配置文件到某个默认目录吧

添加修改mysql配置
mysqld --help --verbose | more (查看帮助, 按空格下翻)

你会看到开始的这一行(表示配置文件默认读取顺序)

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

通常这些位置是没有配置文件的, 所以要自己建一个

ls $(brew --prefix mysql)/support-files/my-* (用这个可以找到样例.cnf)
cp /usr/local/opt/mysql/support-files/my-default.cnf /etc/my.cnf (拷贝到第一个默认读取目录)

按需修改my.cnf

以下是英文资料 摘自http://stackoverflow.com/questions/7973927/for-homebrew-mysql-installs-wheres-my-cnf 最后一段还是比较直白的

There is no my.cnf by default. As such, MySQL starts with all of the default settings. If you want to create your own my.cnf to override any defaults, place it at /etc/my.cnf.

Also, you can run mysql --help and look through it for the conf locations listed.

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
As you can see, there are also some options for bypassing the conf files, or specifying other files to read when you invoke mysql on the command line.

shareimprove this answer
edited Feb 4 '14 at 2:44

answered Nov 2 '11 at 0:14

Jericon
1,614918
15      
This no longer seems to be the case; I see a my.cnf file in /usr/local/Cellar/mysql/5.6.15/ (or whichever version you have installed) – William Turrell Dec 30 '13 at 20:02
3       
@williamt "mysql --help" doesn't list that file as being used, I think it's just a default that comes with the installation files – Vinicius Pinto Jan 27 '14 at 17:01
1       
@williamt I think Vinicius is right. I see /usr/local/Cellar/mysql/5.6.20_1/my.cnf but when I added the log-bin to it and restarted mysqld, it still didn't haven't binary logging enabled. It wasn't until I copied that my.cnf to /etc/my.cnf that binary logging was enabled. Perhaps that my.cnf file is used during the initial install, I'm not sure. – Mark Aug 27 '14 at 20:00

I'm on 5.6.26 and I don't see it there. – Adam Grant Oct 1 at 20:19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值