4.3. Specifying Program Options
There are several ways to specify options for MySQL programs:
List the options on the command line following the program
name. This is most common for options that apply to a specific
invocation of the program.
List the options in an option file that the program reads when
it starts. This is common for options that you want the
program to use each time it runs.
List the options in environment variables. This method is
useful for options that you want to apply each time the
program runs. In practice, option files are used more commonly
for this purpose. However,
Section 5.12.2, “Running Multiple Servers on Unix”, discusses one
situation in which environment variables can be very helpful.
It describes a handy technique that uses such variables to
specify the TCP/IP port number and Unix socket file for both
the server and client programs.
To determine which options are given, MySQL programs first by
examining environment variables, then by reading option files, and
then by checking the command line. If an option is specified
multiple times, the last occurrence takes precedence. This means
that environment variables have the lowest precedence and
command-line options the highest.
You can take advantage of the way that MySQL programs process
options by specifying default values for a program's options in an
option file. That enables you to avoid typing them each time you
run the program, but also allows you to override the defaults if
necessary by using command-line options.