How to find the location of the currently used MySQL configuration file on Linux

How to find out which configuration file MySQL is currently using? Is there any team or something like that?

+50
linux mysql
Jul 17 '10 at 5:02
source share
6 answers

The information you want to find can be found by running

mysql --help 

or

 mysqld --help --verbose 

I tried this command on my machine:

 mysql --help | grep "Default options" -A 1 

And it prints out:

 Default options are read from the following files in the given order: /etc/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 

See if this works for you.

+65
Jul 17 '10 at 5:55
source share

mysqld --help --verbose will only find the location of the default configuration file. What if you use 2 instances of MySQL on the same server? This will not help.

Good article about this:

How to find MySQL configuration file?

+7
Apr 16 2018-12-12T00:
source share

If you are using a terminal, simply enter the following:

 locate my.cnf 
+5
Feb 14 '13 at 7:20
source share

You should find them by default in a folder, for example /etc/my.cnf , perhaps also version dependent. From the MySQL configuration file :

Interestingly, the volume of this file can be set in accordance with its location. Settings will be considered global for all MySQL servers if they are stored in /etc/my.cnf. This will be a globally specific server if it is located in the directory where the MySQL database is (/ usr / local / mysql / data for binary installation or / usr / local / var for source installation). Finally, its scope can be limited to a specific user if the MySQL user located in the home directory (~ / .my.cnf). Keep in mind that even if MySQL detects the my.cnf file in the /etc/my.cnf file (global all MySQL servers on this computer), it will continue to search for the server-specific file, and then the user file. You can think of final configuration options, such as being the result of the /etc/my.cnf, mysql-data-dir / my.cnf and ~ / .my.cnf files.

There are several switches for package managers to display specific files.

RPM Sytems:

The rpm list includes the rpm , -q commands for querying, and -c or --configfiles to display configuration files. There is also -l or --list

--configfiles did not help me, but --list selected several .cnf files stored in mysql-server

 rpm -q --list mysql-server 

DEB systems:

Also with limited success: dpkg --listfiles mysql-server

+1
Jul 17 '10 at 5:10
source share

You can use the ps report process status :

 ps ax | grep '[m]ysqld' 
+1
Nov 12 '13 at 13:52
source share

log into mysql with the appropriate credentials and use mysql> SHOW VARIABLES LIKE 'datadir'; which will give you a way to where mysql is stored

0
May 18 '17 at 19:07
source share



All Articles