Specifying Program Options
233
• List the options on the command line following the program name. This is 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 (see
Section 4.2.4, “Setting 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, but
Section 5.3.3, “Running Multiple MySQL
Instances 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 the server and for client programs.
Options are processed in order, so if an option is specified multiple times, the last occurrence takes
precedence. The following command causes
mysql
to connect to the server running on
localhost
:
shell>
mysql -h example.com -h localhost
If conflicting or related options are given, later options take precedence over earlier options. The
following command runs
mysql
in “no column names” mode:
shell>
mysql --column-names --skip-column-names
MySQL programs determine which options are given first by examining environment variables, then by
reading option files, and then by checking the command line. 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 option
values for a program in an option file. That enables you to avoid typing them each time you run the
program while enabling you to override the defaults if necessary by using command-line options.
An option can be specified by writing it in full or as any unambiguous prefix. For example, the
--
compress
[299]
option can be given to
mysqldump
as
--compr
, but not as
--comp
because the
latter is ambiguous:
shell>
mysqldump --comp
mysqldump: ambiguous option '--comp' (compatible, compress)
Be aware that the use of option prefixes can cause problems in the event that new options are
implemented for a program. A prefix that is unambiguous now might become ambiguous in the future.
4.2.3.1. Using Options on the Command Line
Program options specified on the command line follow these rules:
• Options are given after the command name.
• An option argument begins with one dash or two dashes, depending on whether it is a short form or
long form of the option name. Many options have both short and long forms. For example,
-?
and
--
help
are the short and long forms of the option that instructs a MySQL program to display its help
message.
• Option names are case sensitive.
-v
and
-V
are both legal and have different meanings. (They are
the corresponding short forms of the
--verbose
and
--version
options.)
• Some options take a value following the option name. For example,
-h localhost
or
--
host=localhost
[231]
indicate the MySQL server host to a client program. The option value tells
the program the name of the host where the MySQL server is running.
• For a long option that takes a value, separate the option name and the value by an “
=
” sign. For a
short option that takes a value, the option value can immediately follow the option letter, or there
can be a space between:
-hlocalhost
and
-h localhost
are equivalent. An exception to this
rule is the option for specifying your MySQL password. This option can be given in long form as
--
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...