Search Order for Options Files
The MySQL server and client programs look for options files in the standard locations and read them in order; values from later files take precedence over earlier ones. Options specified on the command line override values from options files.
You can tell a MySQL program to ignore the default options files by telling it to read a specific
file at a location given with the defaults-file
option. For example, you can
write:
$
mysql --defaults-file=
path_to_options_file
If you’d like to use an options file alongside
the default files, you can specify it using the defaults-extra-file
option:
$
mysql --defaults-extra-file=
path_to_local_options_file
Finally, you can prevent programs from reading in any options files by
adding the no-defaults
option:
$
mysql --no-defaults
On a Linux or Mac OS X system, the search order is /etc/my.cnf, then <MySQL_Directory>/my.cnf, defaults-extra-file
, and finally ~/.my.cnf.
Note that for security reasons,
files that are world-writable are ignored. A generally appropriate
permission setting is for the file owner (user) to be able to read and
write the file, but for the group and others to be able to only read
the file. You can set this level of access by opening a terminal
window and typing:
$
chmod u=rw,g=r,o=r
configuration_file
Note that if you’re trying to change the permissions of a file owned
by the system root user, you’ll need to run the chmod
command when logged in as the system root user, or prefix the command with ...
Get Learning MySQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.