1. 程式人生 > >brew mysql 新增修改mysql配置

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

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