Reason:
The MySQL command can be used to connect to the server, but where the data is usually stored, the parameters are set, which requires knowing which configuration file is used by MySQL. (usually my.cnf this configuration problem)
Therefore, it is necessary to clear the MY.CNF loading order.
Default load Order:
|
/ETC/MY.CNF |
global Options |
/ETC/MYSQL/MY.CNF |
|
SYSCONFDIR /my.cnf |
global Options |
$MYSQL _home/my.cnf |
server-specific options |
defaults-file|extra-file |
the file specified with --defaults-extra-file=path ... |
~/my.cnf |
User-specific Options |
Reading order
1,/ETC/MY.CNF
The general configuration file will be here, of course, when MySQL starts the service, it will read the configuration file by default. (multi-instance MySQL to be cautious!) )
2./etc/mysql/my.cnf
一般系统etc并没有mysql这个目录,如果需要自己创建。
3, SYSCONFDIR /my.cnf
basedir/my.cnf
4, $MYSQL _home/my.cnf
datadir/my.cnf
5, plus start the specified parameters
-defaults-file=#, read only the specified file (no longer read other configuration files)
-defaults-extra-file=#, read the global configuration from other higher-priority profiles before reading the specified configuration file.
6、~/my.cnf
Tips:
1, assume that 4 configuration files are present, also use the--defaults-extra-file specified parameter file, if there is a "parameter variable" in the 5 configuration file appears, then the parameter value in the configuration file will overwrite the parameter variable value in the previous configuration file, This means that the value set in ~/.MY.CNF is used.
2、/usr/local/mysqltwo/bin/mysqld--verbose--help |grep-a 1 ' Default options '
Without excluding the version of the problem, some paths will be different. For example, some paths are my.cnf under/usr
The specific reading order can be based on your own version and official manuals!
This article from the "[email protected]" blog, reproduced please contact the author!
Experience-mysql configuration file reading order problem!