在红帽Linux系统上,MySQL配置文件的默认位置是什么?
刚发现,它是 /etc/my.cnf
您想要的信息可以通过运行以下代码找到:
mysql --help
或者mysqld --help --verbose
我尝试了这个:
mysql --help | grep Default -A 1
输出结果为:
(Defaults to on; use --skip-auto-rehash to disable.)
-A, --no-auto-rehash
--
(Defaults to on; use --skip-line-numbers to disable.)
-L, --skip-line-numbers
--
(Defaults to on; use --skip-column-names to disable.)
-N, --skip-column-names
--
(Defaults to on; use --skip-reconnect to disable.)
-s, --silent Be more silent. Print results with a tab as separator,
--
--default-auth=name Default authentication client-side plugin to use.
--binary-mode By default, ASCII '\0' is disallowed and '\r\n' is
--
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
/etc/mysql/my.cnf
。所有人都是好的候选者:
/etc/my.cnf
/etc/mysql/my.cnf
/var/lib/mysql/my.cnf
...
在许多情况下,您可以使用ps命令来检查系统进程列表:
server ~ # ps ax | grep '[m]ysqld'
输出
10801 ? Ssl 0:27 /usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock
或者
which mysqld
/usr/sbin/mysqld
那么
/usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf
在RH系统上,MySQL的配置文件默认位于/etc/my.cnf。
默认选项按照给定顺序从以下文件中读取:
/etc/mysql/my.cnf
/etc/my.cnf
~/.my.cnf
从 '/etc/mysql/my.cnf' 的头部:
MariaDB programs look for option files in a set of
locations which depend on the deployment platform.
[...] For information about these locations, do:
'my_print_defaults --help' and see what is printed under
"Default options are read from the following files in the given order:"
More information at: http://dev.mysql.com/doc/mysql/en/option-files.html
/usr/libexec/mysqld --help --verbose
而不是mysqld --help --verbose
有效。 - Andron