Specifying Connection Parameters Using Option Files
Problem
You don’t want to type connection parameters on the command line every time you invoke mysql or other MySQL programs.
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 installation directory. Under Windows, the option files you can use are the my.ini file in your MySQL installation directory (for example, C:\Program Files\MySQL\MySQL Server 5.0), my.ini in your Windows directory (this is something like C:\WINDOWS or C:\WINNT), or the C:\my.cnf file.
Windows Explorer might hide filename extensions when it displays
files, so a file named my.ini or
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 console window to see
complete filenames.
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] skip-auto-rehash pager="/usr/bin/less -E" # specify pager for interactive mode
This format has the following ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access