Is there a MySQL command to locate the
my.cnf configuration file, similar to how PHP's
phpinfo() locates its
You can actually ask MySQL to show you the list of all locations where it searches for my.cnf (or my.ini on Windows). It is not an SQL command though. Rather, execute:
$ mysqld --help --verbose
In the very first lines you will find a message with a list of all my.cnf locations it looks for. On my machine it 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
Or, on Windows:
Default options are read from the following files in the given order: C:Windowsmy.ini C:Windowsmy.cnf C:my.ini C:my.cnf C:Program FilesMySQLMySQL Server 5.5my.ini C:Program FilesMySQLMySQL Server 5.5my.cnf
Note however, that it might be that there is no my.cnf file at any of these locations. So, you can create the file on your own - use one of the sample config files provided with MySQL distribution (on Linux - see
/usr/share/mysql/*.cnf files and use whichever is appropriate for you - copy it to
/etc/my.cnf and then modify as needed).
Also, note that there is also a command line option
--defaults-file which may define custom path to my.cnf or my.ini file. For example, this is the case for MySQL 5.5 on Windows - it points to a my.ini file in the data directory, which is not normally listed with
mysqld --help --verbose. On Windows - see service properties to find out if this is the case for you.
Finally, check the http://dev.mysql.com/doc/refman/5.5/en/option-files.html - it is described there in more details.
Edit 2017 - MySQL 5.7+
In MySQL 5.7 use: