Database Reference
In-Depth Information
eters that apply globally to all users. You can use the
my.cnf
file in the
/etc
or
/etc/
mysql
directory, or in the
etc
directory under the MySQL installation directory.
• Under Windows, files you can use include the
my.ini
or
my.cnf
file in your MySQL
installation directory (for example,
C:\Program Files\MySQL\MySQL Server 5.6
),
your Windows directory (likely
C:\WINDOWS
), or the
C:\
directory.
To see the exact list of permitted option-file locations, invoke
mysql
--help
.
The following example illustrates the format used in MySQL option files:
# general client program connection options
[client]
host = localhost
user = cbuser
password = cbpass
# options specific to the mysql program
[mysql]
skip-auto-rehash
pager="/usr/bin/less -E" # specify pager for interactive mode
With connection parameters listed in the
[client]
group as just shown, you can con‐
nect as
cbuser
by invoking
mysql
with no options on the command line:
%
mysql
The same holds for other MySQL client programs, such as
mysqldump
.
MySQL option files have these characteristics:
• Lines are written in groups (or sections). The first line of a group specifies the group
name within square brackets, and the remaining lines specify options associated
with the group. The example file just shown has a
[client]
group and a
[mysql]
group. To specify options for the server,
mysqld
, put them in a
[mysqld]
group.
• The usual option group for specifying client connection parameters is
[client]
.
This group actually is used by all the standard MySQL clients. By listing an option
in this group, you make it easier to invoke not only
mysql
, but also other programs
such as
mysqldump
and
mysqladmin
. Just make sure that any option you put in this
group is understood by
all
client programs. Otherwise, invoking any client that does
not understand it results in an “unknown option” error.
• You can define multiple groups in an option file. By convention, MySQL clients
look for parameters in the
[client]
group and in the group named for the program
itself. This provides a convenient way to list general client parameters that you want
all client programs to use, but you can still specify options that apply only to a
particular program. The preceding sample option file illustrates this convention for
the
mysql
program, which gets general connection parameters from the
[client]