http://dev.mysql.com/doc/refman/5.6/en/option-files.html
Linuxで公式MySQL、--defaults-file, --defaults-extra-fileを指定しない場合は、
- /etc/my.cnf
- /etc/mysql/my.cnf
- /usr/local/mysql/etc/my.cnf
- SYSCONFDIR/my.cnfのこと。
- 公式のバイナリーはSYSCONFDIR== /usr/local/mysql/etc。cmakeのオプションで変えられる。
- MariaDBはこいつが設定されていないっぽい。
- /usr/local/mysql/my.cnf
- $MYSQL_HOME/my.cnfのこと。
- basedirを設定してれば$MYSQL_HOME== basedirになる。
- /home/mysql/.my.cnf
- $HOME/.my.cnfのこと。コイツだけドットファイル。
とはいえこんなのめんどくさくて憶えてられなかったり、SYSCONFDIRやMYSQL_HOMEが思いもしない変なところになってたりすることがあったりなかったりするかも知れないので、調べ方だけメモってみる。
# strace -ff -e open -e stat /usr/mysql/5.5.34/bin/mysqld_multi start 55,56 2>&1 | grep "my\.cnf" [pid 7359] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 [pid 7359] stat("/etc/mysql/my.cnf", 0x7fffa1322e40) = -1 ENOENT (No such file or directory) [pid 7359] stat("/usr/local/mysql/etc/my.cnf", 0x7fffa1322e40) = -1 ENOENT (No such file or directory) [pid 7359] stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 stat("/etc/mysql/my.cnf", 0x1739130) = -1 ENOENT (No such file or directory) stat("/usr/mysql/5.5.34/my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 stat("/usr/mysql/5.5.34/my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 7361] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 [pid 7361] stat("/etc/mysql/my.cnf", 0x7fffdaeb46e0) = -1 ENOENT (No such file or directory) [pid 7361] stat("/usr/local/mysql/etc/my.cnf", 0x7fffdaeb46e0) = -1 ENOENT (No such file or directory) [pid 7361] stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 7365] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 [pid 7365] stat("/etc/mysql/my.cnf", 0x7fff4038abf0) = -1 ENOENT (No such file or directory) [pid 7365] stat("/usr/local/mysql/etc/my.cnf", 0x7fff4038abf0) = -1 ENOENT (No such file or directory) [pid 7365] stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 7371] stat("/usr/mysql/5.6.14/data/my.cnf", 0x7fff0d4bc2b0) = -1 ENOENT (No such file or directory) [pid 7371] stat("/usr/mysql/5.6.14/my.cnf", 0x7fff0d4bc2c0) = -1 ENOENT (No such file or directory) [pid 7371] stat("/usr/mysql/5.6.14/data/my.cnf", 0x7fff0d4bc320) = -1 ENOENT (No such file or directory) [pid 7407] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 [pid 7407] stat("/etc/mysql/my.cnf", 0x7fff380ae700) = -1 ENOENT (No such file or directory) [pid 7407] stat("/usr/local/mysql/etc/my.cnf", 0x7fff380ae700) = -1 ENOENT (No such file or directory) [pid 7407] stat("/usr/mysql/5.6.14/my.cnf", 0x7fff380ae700) = -1 ENOENT (No such file or directory) [pid 7407] stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 7364] stat("/usr/mysql/5.5.34/data/my.cnf", 0x7fffb0b1a980) = -1 ENOENT (No such file or directory) [pid 7364] stat("/usr/mysql/5.5.34/my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 7364] stat("/usr/mysql/5.5.34/data/my.cnf", 0x7fffb0b1a990) = -1 ENOENT (No such file or directory) [pid 7364] stat("/usr/mysql/5.5.34/data/my.cnf", 0x7fffb0b1a9f0) = -1 ENOENT (No such file or directory) [pid 7421] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 [pid 7421] stat("/etc/mysql/my.cnf", 0x7fffde0a77e0) = -1 ENOENT (No such file or directory) [pid 7421] stat("/usr/local/mysql/etc/my.cnf", 0x7fffde0a77e0) = -1 ENOENT (No such file or directory) [pid 7421] stat("/usr/mysql/5.5.34/my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 7421] stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 8339] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 [pid 8339] stat("/etc/mysql/my.cnf", 0x7fff59e821d0) = -1 ENOENT (No such file or directory) [pid 8339] stat("/usr/local/mysql/etc/my.cnf", 0x7fff59e821d0) = -1 ENOENT (No such file or directory) [pid 8339] stat("/usr/mysql/5.6.14/my.cnf", 0x7fff59e821d0) = -1 ENOENT (No such file or directory) [pid 8339] stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 8416] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=3584, ...}) = 0 [pid 8416] stat("/etc/mysql/my.cnf", 0x7fffc5f4d310) = -1 ENOENT (No such file or directory) [pid 8416] stat("/usr/local/mysql/etc/my.cnf", 0x7fffc5f4d310) = -1 ENOENT (No such file or directory) [pid 8416] stat("/usr/mysql/5.5.34/my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 [pid 8416] stat("/root/.my.cnf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
実際どれを開いたかだけでよければ、"-e stat"はイラナイ。
小ネタ、小ネタ。
【2015/02/18 19:39】
mysqldの読むやつ見たいんだったらmysqld --help --verboseでいいじゃん? って何度か言われてたので追記。
mysqld --help --verboseだと、my.cnfに設定したbasedirの値が読み取られる前にパスが解釈されるので、MYSQL_HOME/my.cnfが表示されない。
$ /usr/mysql/5.6.23/bin/mysqld --help --verbose | grep cnf /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default 2015-02-19 19:35:47 29891 [Note] Binlog end 2015-02-19 19:35:47 29891 [Note] Shutting down plugin 'CSV' 2015-02-19 19:35:47 29891 [Note] Shutting down plugin 'MyISAM' $ strace -f -e stat /usr/mysql/5.6.23/bin/mysqld 2>&1 | grep my\.cnf stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=4456, ...}) = 0 stat("/etc/mysql/my.cnf", 0x7fffd4f430d0) = -1 ENOENT (No such file or directory) stat("/usr/local/mysql/etc/my.cnf", 0x7fffd4f430d0) = -1 ENOENT (No such file or directory) stat("/home/yoku0825/.my.cnf", 0x7fffd4f430d0) = -1 ENOENT (No such file or directory) $ strace -f -e stat /usr/mysql/5.6.23/bin/mysqld_safe 2>&1 | grep my\.cnf stat("/usr/mysql/5.6.23/data/my.cnf", 0x7fff56f127f0) = -1 ENOENT (No such file or directory) stat("/usr/mysql/5.6.23/my.cnf", {st_mode=S_IFREG|0664, st_size=943, ...}) = 0 stat("/usr/mysql/5.6.23/data/my.cnf", 0x7fff56f12800) = -1 ENOENT (No such file or directory) stat("/usr/mysql/5.6.23/data/my.cnf", 0x7fff56f12860) = -1 ENOENT (No such file or directory) [pid 28434] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=4456, ...}) = 0 [pid 28434] stat("/etc/mysql/my.cnf", 0x7ffffdd236c0) = -1 ENOENT (No such file or directory) [pid 28434] stat("/usr/local/mysql/etc/my.cnf", 0x7ffffdd236c0) = -1 ENOENT (No such file or directory) [pid 28434] stat("/usr/mysql/5.6.23/my.cnf", {st_mode=S_IFREG|0664, st_size=943, ...}) = 0 [pid 28434] stat("/home/yoku0825/.my.cnf", 0x7ffffdd236c0) = -1 ENOENT (No such file or directory) [pid 28916] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=4456, ...}) = 0 [pid 28916] stat("/etc/mysql/my.cnf", 0x7fff43cc1bd0) = -1 ENOENT (No such file or directory) [pid 28916] stat("/usr/local/mysql/etc/my.cnf", 0x7fff43cc1bd0) = -1 ENOENT (No such file or directory) [pid 28916] stat("/usr/mysql/5.6.23/my.cnf", {st_mode=S_IFREG|0664, st_size=943, ...}) = 0 [pid 28916] stat("/home/yoku0825/.my.cnf", 0x7fff43cc1bd0) = -1 ENOENT (No such file or directory) [pid 29004] stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=4456, ...}) = 0 [pid 29004] stat("/etc/mysql/my.cnf", 0x7fff76cacf80) = -1 ENOENT (No such file or directory) [pid 29004] stat("/usr/local/mysql/etc/my.cnf", 0x7fff76cacf80) = -1 ENOENT (No such file or directory) [pid 29004] stat("/usr/mysql/5.6.23/my.cnf", {st_mode=S_IFREG|0664, st_size=943, ...}) = 0 [pid 29004] stat("/home/yoku0825/.my.cnf", 0x7fff76cacf80) = -1 ENOENT (No such file or directory)
よく憶えてないんだけど、たぶんこれがラッパーに隠蔽されて(mysql.serverが中でゴニョゴニョやってるとかそんなの)るのが嫌でstraceで取ったんじゃないかなぁと思う。
$ MYSQL_HOME=/usr/mysql/5.6.23 /usr/mysql/5.6.23/bin/mysqld --help --verbose | grep cnf /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf /usr/mysql/5.6.23/my.cnf ~/.my.cnf my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default 2015-02-19 19:35:18 29889 [Note] Binlog end 2015-02-19 19:35:18 29889 [Note] Shutting down plugin 'CSV' 2015-02-19 19:35:18 29889 [Note] Shutting down plugin 'MyISAM'
$MYSQL_HOMEをちゃんと環境変数で与えておけば、mysqld --help --verboseでも見える。
あとはmy.cnfに!include が書いてあるケースとかも--help --verboseでは拾えないなぁとかそんなことをぼんやりと。
0 件のコメント :
コメントを投稿