Database Reference
In-Depth Information
and the password) or --password= password . I don't recommend this because the pass‐
word is visible to onlookers and, on multiple-user systems, may be discoverable to other
users who run tools such as ps that report process information.
Because the default host is localhost , the same value we've been specifying explicitly,
you can omit the -h (or --host ) option from the command line:
% mysql -u cbuser -p
But suppose that you'd really rather not specify any options. How can you get mysql to
“just know” what values to use? That's easy because MySQL programs support option
files:
• If you put an option in an option file, you need not specify it on the command line
each time you invoke a given program.
• You can mix command-line and option-file options. This enables you to store the
most commonly used option values in a file but override them as desired on the
command line.
The rest of this section describes these capabilities.
The Meaning of localhost in MySQL
One of the parameters you specify when connecting to a MySQL server is the host where
the server is running. Most programs treat the hostname localhost and the IP address
127.0.0.1 as synonyms for “the local host.” Under Unix, MySQL programs behave
differently: by convention, they treat the hostname localhost specially and attempt to
connect to the local server using a Unix domain socket file. To force a TCP/IP connection
to the local server, use the IP address 127.0.0.1 (or ::1 if your system is configured to
support IPv6) rather than the hostname localhost . Alternatively, you can specify a --
protocol=tcp option to force use of TCP/IP for connecting.
The default port number is 3306 for TCP/IP connections. The pathname for the Unix
domain socket varies, although it's often /tmp/mysql.sock . To name the socket file path‐
name explicitly, use -S file_name or --socket= file_name .
Specifying connection parameters using option files
To avoid entering options on the command line each time you invoke mysql , put them
in an option file for mysql to read automatically. Option files are plain-text files:
• 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 param‐
 
Search WWH ::




Custom Search