What is the default location for the MySQL configuration file on a redhat linux box?
Asked
Active
Viewed 1.7e+01k times
8 Answers
44
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
![](../../users/profiles/858515.webp)
ThinkingMonkey
- 12,011
- 12
- 51
- 80
-
For me `/usr/libexec/mysqld --help --verbose` worked instead of `mysqld --help --verbose` – Andron Apr 01 '13 at 15:36
-
1@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
6
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
![](../../users/profiles/1261959.webp)
Nullpointer
- 1,468
- 16
- 20
5
Default options are read from the following files in the given order:
/etc/mysql/my.cnf
/etc/my.cnf
~/.my.cnf
![](../../users/profiles/6244.webp)
Toby Allen
- 10,562
- 10
- 70
- 120
![](../../users/profiles/2315938.webp)
B_e_n_n_y_
- 61
- 1
- 5
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
![](../../users/profiles/3216341.webp)
divandc
- 129
- 5