Specifying Connection Parameters by Using Option Files
Problem
You don’t want to type connection parameters on the command line every time you invoke mysql.
Solution
Put the parameters in an option file.
Discussion
To avoid entering connection parameters manually, put them in an
option file for mysql to read automatically. Under
Unix, your personal option file is named
.my.cnf in your home directory. There are also
site-wide option files that administrators can use to specify
parameters that apply globally to all users. You can use
/etc/my.cnf or the my.cnf
file in the MySQL server’s data directory. Under
Windows, the option files you can use are
C:\my.cnf, the my.ini file
in your Windows system directory, or my.cnf in
the server’s data directory.
Tip
Windows may hide
filename extensions when
displaying files, so a file named my.cnf may
appear to be named just my. Your version of
Windows may allow you to disable extension-hiding. Alternatively,
issue a DIR command in a DOS window to see full
names.
The following example illustrates the format used to write MySQL option files:
# general client program connection options [client] host=localhost user=cbuser password=cbpass # options specific to the mysql program [mysql] no-auto-rehash # specify pager for interactive mode pager=/usr/bin/less
This format has the following general characteristics:
Lines are written in groups. The first line of the group specifies the group name inside of square brackets, and the remaining lines specify options ...