Home » Linux » MySQL config file location – redhat linux server

MySQL config file location – redhat linux server

Posted by: admin November 30, 2017 Leave a comment

Questions:

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

Answers:

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

Questions:
Answers:

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 '
 (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 
' 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

Questions:
Answers:

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

Questions:
Answers:

Default options are read from the following files in the given order:

/etc/mysql/my.cnf 
/etc/my.cnf 
~/.my.cnf 

Questions:
Answers:

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

Questions:
Answers:

On RH systems, MySQL configuration file is located under /etc/my.cnf by default. If you use more instances on single server or not standard config location, check:

http://www.dbasquare.com/kb/where-is-mysql-configuration-file/
http://www.dbasquare.com/2012/04/01/how-to-find-mysql-configuration-file/

Questions:
Answers:

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

Questions:
Answers:

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

/etc/mysql/my.cnf