40

What is the default location for the MySQL configuration file on a redhat linux box?

user42931
  • 991
  • 2
  • 9
  • 12

8 Answers8

49

Just found it, it is /etc/my.cnf

user42931
  • 991
  • 2
  • 9
  • 12
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 
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
19

it is located at /etc/mysql/my.cnf

Adrien Plisson
  • 19,742
  • 4
  • 38
  • 71
Nugatu
  • 199
  • 1
  • 2
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
Nullpointer
  • 1,468
  • 16
  • 20
5

On RH systems, MySQL configuration file is located under /etc/my.cnf by default.

Kaii
  • 18,421
  • 3
  • 33
  • 58
Sasha
  • 385
  • 5
  • 5
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,562
  • 10
  • 70
  • 120
B_e_n_n_y_
  • 61
  • 1
  • 5
3

In the docker containers(centos based images) it is located at

/etc/mysql/my.cnf

Jauyzed
  • 442
  • 3
  • 15
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
  • 129
  • 5