查看 MySQL 配置文件路径

有的时候别人安装的 MySQL 自己不知道配置文件在哪里。可以用下面的命令查看配置文件的位置。

$ mysqld --verbose --help | grep -A 1 'Default options'
2017-03-12 18:11:29 0 [Note] mysqld (mysqld 5.6.26) starting as process 21216 ...
2017-03-12 18:11:29 21216 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2017-03-12 18:11:29 21216 [Note] Plugin 'FEDERATED' is disabled.
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
2017-03-12 18:11:29 21216 [Note] Binlog end
2017-03-12 18:11:29 21216 [Note] Shutting down plugin 'MyISAM'
2017-03-12 18:11:29 21216 [Note] Shutting down plugin 'CSV'