What is the default location for the MySQL configuration file on a redhat linux box?
Asked
Active
Viewed 2.1e+01k times
8 Answers
48
The information you want can be found by running
mysql --help
or
mysqld --help --verbose
I tried this :
mysql --help | grep Default -A 1
And the output:
(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

ThinkingMonkey
- 12,539
- 13
- 57
- 81
-
For me `/usr/libexec/mysqld --help --verbose` worked instead of `mysqld --help --verbose` – Andron Apr 01 '13 at 15:36
-
2@Andron yes if the path to executable daemon is not in the ENV PATH, you will have to specify the absolute path to the daemon executable. – ThinkingMonkey Apr 01 '13 at 18:21
8
All of them seemed good candidates:
/etc/my.cnf
/etc/mysql/my.cnf
/var/lib/mysql/my.cnf
...
in many cases you could simply check system process list using ps:
server ~ # ps ax | grep '[m]ysqld'
Output
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
Or
which mysqld
/usr/sbin/mysqld
Then
/usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf

Nullpointer
- 1,895
- 20
- 26
5
Default options are read from the following files in the given order:
/etc/mysql/my.cnf
/etc/my.cnf
~/.my.cnf

Toby Allen
- 10,997
- 11
- 73
- 124
1
From the header of '/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

divandc
- 149
- 5