mysql配置文件讀取順序

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
讀取順序爲:
/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=<配置文件的絕對路徑>參數,這時只會使用這個參數指定的配置文件。

發佈了23 篇原創文章 · 獲贊 13 · 訪問量 44萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章