File Locations

On Unix systems, MySQL looks in the following locations—in order—for configuration files:

  1. In the /etc/my.cnf file. The first place MySQL looks is the global options file. In general, you will want to place the default options to be used by all users and all servers in this file.

  2. In the DATADIR/my.cnf file. DATADIR is the directory where a MySQL server instance keeps its datafiles. This configuration file exists specifically for configuration parameters specific to a given server instance.

  3. In the location specified through the --defaults-extra-file=filename command-line option. This command-line option enables the MySQL server or client utilities to look in an arbitrary location for a configuration file.

  4. In the $HOME/.my.cnf file. $HOME is the Unix environment variable that holds the home directory of the current user. This configuration file in a user’s home directory is where individual users can keep their user-specific options. This location is where most client options are specified.

Windows has an extra global configuration file and no user-specific configuration file:

  1. My.ini in the Windows system folder—generally C:\WINNT\System32

  2. C:\my.cnf

  3. C:\mysql\data\my.cnf

  4. --defaults-extra-file= filename

If any option appears in multiple files, the last one read overrides the others. In other words, the user-defined options in C:\my.cnf override any values read from My.ini. This behavior makes it possible for a database administrator to provide default values ...

Get Managing & Using MySQL, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.