Specifying Program Options
241
Be aware that the use of variable prefixes can cause problems in the event that new variables are
implemented for a program. A prefix that is unambiguous now might become ambiguous in the future.
Suffixes for specifying a value multiplier can be used when setting a variable at server startup, but not
to set the value with
SET
at runtime. On the other hand, with
SET
you can assign a variable's value
using an expression, which is not true when you set a variable at server startup. For example, the first
of the following lines is legal at server startup, but the second is not:
shell>
mysql --max_allowed_packet=16M
shell>
mysql --max_allowed_packet=16*1024*1024
Conversely, the second of the following lines is legal at runtime, but the first is not:
mysql>
SET GLOBAL max_allowed_packet=16M;
mysql>
SET GLOBAL max_allowed_packet=16*1024*1024;
Note
Before MySQL 4.0.2, the only syntax for setting program variables was
--set-
variable=option=value
(or
set-variable=option=value
in option
files). Underscores cannot be given as dashes, and the variable name must
be specified in full. This syntax still is recognized, but is now deprecated and is
removed in MySQL 5.5.
4.2.3.6. Option Defaults, Options Expecting Values, and the
=
Sign
By convention, long forms of options that assign a value are written with an equals (
=
) sign, like this:
shell>
mysql --host=tonfisk --user=jon
For options that require a value (that is, not having a default value), the equal sign is not required, and
so the following is also valid:
shell>
mysql --host tonfisk --user jon
In both cases, the
mysql
client attempts to connect to a MySQL server running on the host named
“tonfisk” using an account with the user name “jon”.
Due to this behavior, problems can occasionally arise when no value is provided for an option that
expects one. Consider the following example, where a user connects to a MySQL server running on
host
tonfisk
as user
jon
:
shell>
mysql --host 85.224.35.45 --user jon
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.96 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| jon@% |
+----------------+
1 row in set (0.00 sec)
Omitting the required value for one of these option yields an error, such as the one shown here:
shell>
mysql --host 85.224.35.45 --user
mysql: option '--user' requires an argument
In this case,
mysql
was unable to find a value following the
--user
[232]
option because nothing
came after it on the command line. However, if you omit the value for an option that is not the last
option to be used, you obtain a different error that you may not be expecting:
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...