tags:

views:

101

answers:

4

please tell me is there any mysql command to determine the my.cnf configuration file location just like phpinfo() to determine php.ini file.

Thank you.

A: 

I don't know how you've setup MySQL on your Linux environment but have you checked?

  • /etc/my.cnf
The Elite Gentleman
+2  A: 

You could always run find in a terminal.

find / -name my.cnf
Dyllon
it's the hard way :(Is there any mysql command like the phpinfo() to know the config file location ?
robinmag
`find / -name my.cnf` is your best bet, but you could also check your home directory and /etc/mysql/my.confYou can also see if your MYSQL_HOME is set by typing `echo $MYSQL_HOME` in a terminal
Dyllon
Wow, that would take forever on most machines. Most modern linuxes have locate installed and so long as updatedb is run regularly you can do a:locate my.cnf | less
+1  A: 

There is no internal MySQL command to trace this, it's a little too abstract. The file might be in 5 (or more?) locations, and they would all be valid because they load cascading.

  • /etc/my.cnf
  • /etc/mysql/my.cnf
  • $MYSQL_HOME/my.cnf
  • [datadir]/my.cnf
  • ~/.my.cnf

Those are the default locations MySQL looks at. If it finds more than one, it will load each of them & values override each other (in the listed order, I think). Also, the --defaults-file parameter can override the whole thing, so... basically, it's a huge pain in the butt.

But thanks to it being so confusing, there's a good chance it's just in /etc/my.cnf.

(if you just want to see the values: SHOW VARIABLES, but you'll need the permissions to do so.)

tadamson
A: 

This might work:

strace mysql ";" 2>&1  | grep cnf

on my machine this outputs:

stat64("/etc/my.cnf", 0xbf9faafc)       = -1 ENOENT (No such file or directory)
stat64("/etc/mysql/my.cnf", {st_mode=S_IFREG|0644, st_size=4271, ...}) = 0
open("/etc/mysql/my.cnf", O_RDONLY|O_LARGEFILE) = 3
read(3, "# /etc/mysql/my.cnf: The global "..., 4096) = 4096
stat64("/home/xxxxx/.my.cnf", 0xbf9faafc) = -1 ENOENT (No such file or directory)

So it looks like /etc/mysql/my.cnf is the one since it stat64() and read() were successful.

Chuck Ross