[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Program options specified on the command line follow these rules:
-?
and --help
are the short and long forms
of the option that instructs a MySQL program to display a help message.
-v
and -V
are both legal and
have different meanings. (They are the corresponding short forms of the
--verbose
and --version
options.)
-h localhost
or --host=localhost
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.
-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 --password=pass_val
or as
--password
. In the latter case (with no password value given), the
program will prompt you for the password.
The password option also may be given in short form as -ppass_val
or as
-p
. However, for the short form, if the password value is given, it
must follow the option letter with no intervening space. The reason for
this is that if a space follows the option letter, the program has no way to
tell whether a following argument is supposed to be the password value or some
other kind of argument. Consequently, the following two commands have two
completely different meanings:
shell> mysql -ptest shell> mysql -p test |
The first command instructs mysql
to use a password value of
test
, but specifies no default database.
The second instructs mysql
to prompt for the password value
and to use test
as the default database.
MySQL 4.0 introduced some additional flexibility in the way you specify options. These changes were made in MySQL 4.0.2. Some of them relate to the way you specify options that have "enabled" and "disabled" states, and to the use of options that may be present in one version of MySQL but not another. Those capabilities are discussed here. Another change pertains to the way you use options to set program variables. 4.3.4 Using Options to Set Program Variables discusses that topic further.
Some options control behavior that can be turned on or off. For example,
the mysql
client supports a --column-names
option that
determines whether or not to display a row of column names at the beginning
of query results. By default, this option is enabled. However, you may
want to disable it in some instances, such as when sending the output
of mysql
into another program that expects to see only data and
not an initial header line.
To disable column names, you can specify the option using any of these forms:
--disable-column-names --skip-column-names --column-names=0 |
The --disable
and --skip
prefixes and the =0
suffix
all have the same effect of turning the option off.
The "enabled" form of the option may be specified as:
--column-names --enable-column-names --column-names=1 |
Another change to option processing introduced in MySQL 4.0 is that you
can use the --loose
prefix for command-line options. If an option
is prefixed by --loose
, the program will not exit with
an error if it does not recognize the option, but instead will issue
only a warning:
shell> mysql --loose-no-such-option mysql: WARNING: unknown option '--no-such-option' |
The --loose
prefix can be useful when you run programs from
multiple installations of MySQL on the same machine, at least if all the
versions are as recent as 4.0.2. This prefix is particularly useful when you
list options in an option file. An option that may not be recognized by all
versions of a program can be given using the --loose
prefix (or loose
in an option file). Versions of the program that do
not recognize the option will issue a warning and ignore it. Note that this
strategy works only if all versions involved are 4.0.2 or later, because
earlier versions know nothing of the --loose
convention.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |