Option Files Read on Unix and Unix-Like Systems
| 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 (server only) |
| defaults-extra-file | The file specified with --defaults-extra-file, if any |
| ~/.my.cnf | User-specific options |
| ~/.mylogin.cnf | User-specific login path options (clients only) |
| DATADIR/mysqld-auto.cnf | System variables persisted with SET PERSIST or SE PERSIST_ONLY (server only) |
Option Files Read on Windows Systems
| File Name | Purpose |
|---|---|
| %WINDIR%\my.ini, %WINDIR%\my.cnf | Global options |
| C:\my.ini, C:\my.cnf | Global options |
| BASEDIR\my.ini, BASEDIR\my.cnf | Global options |
| defaults-extra-file | The file specified with --defaults-extra-file, if any |
| %APPDATA%\MySQL.mylogin.cnf | Login path options (clients only) |
| DATADIR\mysqld-auto.cnf | System variables persisted with SET PERSIST or SET PERSIST_ONLY (server only) |
如果找到给定选项的多个实例,则最后一个实例优先
意思是后一个的配置文件会覆盖之前的配置