位置
On Unix and Unix-like systems, MySQL programs read startup options from the files shown in the following table, in the specified order (top files are read first, files read later take precedence).
翻譯:
在unix和類unix系統(tǒng)中,mysql程序從以下表格列出的配置文件中按順序讀取啟動配置項(在上面的先讀取,后面的后讀取擁有優(yōu)先生效的權(quán)利)
| 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, if any |
| ~/.my.cnf | User-specific options |
| ~/.mylogin.cnf | User-specific login path options (clients only) |
使用
- comment或者;comment代表注釋
- [group]代表分組,生效于某個命令,例如[client][mysqld]
- opt_name,沒有前導(dǎo)兩個橫崗,代表選項
- opt_name=value,沒有前導(dǎo)兩個橫崗,代表選項與值
- 示例
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
port=3306
socket=/tmp/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M
[mysqldump]
quick
- 可以使用!include或者!includedir來包含.cnf后綴的其它配置文件
- 數(shù)字值的選項可以使用K,M,G(不區(qū)分大小寫)作為后綴來代表1024以及它的2次方,3次方