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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM