之前对 MySQL 的配置文件选取优先级一直感到困惑,因为之前一直用 /etc/my.cnf 作为配置文件,今天读取手册,刚好看到配置文件my.cnf 读取优先级的问题,记录下备忘。
手册中的解释
On Unix, Linux and Mac OS X, MySQL programs read startup options from the following files, in the specified order (top items are used first).
| File Name | Purpose |
|---|---|
| /etc/my.cnf | Global options |
| /etc/mysql/my.cnf | Global options |
| SYSCONFDIR/my.cnf | Global options |
| $MYSQL_HOME/my.cnf | Server-specific options |
| defaults-extra-file | The file specified with –defaults-extra-file=path, if any |
| ~/.my.cnf | User-specific options |
| ~/.mylogin.cnf | Login path options |
备注:今天将配置文 $MYSQL_HOME/my.cnf, /etc/my.cnf 各设置一份,发现参数还是以 $MYSQL_HOME/my.cnf 为准,并没有按文档中的优先顺序,感觉 mysql 服务将配置文件从上到下依次都了一遍,然后将之前读的配置覆盖了,很奇怪。
参考
原创文章,作者:306829225,如若转载,请注明出处:https://blog.ytso.com/tech/bigdata/239606.html