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 |
|
Global options |
$MYSQL_HOME/my.cnf |
Server-specific options |
defaults-extra-file |
The file specified with --defaults-extra-file= , if any |
~/.my.cnf |
User-specific options |
/etc/my.cnf
basedir/my.cnf
datadir/my.cnf
--defaults-extra-file #在讀取全局配置文件之后,讀取用戶配置文件(~/.my.cnf)之前,讀取extra指定的參數文件
~/.my.cnf #家目錄下面的隱藏文件,my.cnf前面的點,說明my.cnf是隱藏文件
假設4個配置文件都存在,同時使用--defaults-extra-file指定了參數文件,如果這時有一個 "參數變量"在5個配置文件中都出現了,那么后面的配置文件中的參數變量值 會 覆蓋 前面配置文件中的參數變量值,就是說會使用~/.my.cnf中設置的值。
*****注意*****
如果使用./bin/mysqld_safe 守護進程啟動mysql數據庫時,使用了 --defaults-file=<配置文件的絕對路徑>參數,這時只會使用這個參數指定的配置文件。