<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="command-line-options">
      </a>
      6.2.2.1 Using Options on the Command Line
     </h4>
    </div>
   </div>
  </div>
  <p>
   Program options specified on the command line follow these
        rules:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Options are given after the command name.
     </p>
    </li>
    <li class="listitem">
     <p>
      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,
      <code class="option">
       -?
      </code>
      and
      <code class="option">
       --help
      </code>
      are the short and long forms of the option that instructs a
            MySQL program to display its help message.
     </p>
    </li>
    <li class="listitem">
     <p>
      Option names are case-sensitive.
      <code class="option">
       -v
      </code>
      and
      <code class="option">
       -V
      </code>
      are both legal and have different
            meanings. (They are the corresponding short forms of the
      <code class="option">
       --verbose
      </code>
      and
      <code class="option">
       --version
      </code>
      options.)
     </p>
    </li>
    <li class="listitem">
     <p>
      Some options take a value following the option name. For
            example,
      <code class="option">
       -h localhost
      </code>
      or
      <a class="link" href="connection-options.html#option_general_host">
       <code class="option">
        --host=localhost
       </code>
      </a>
      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.
     </p>
    </li>
    <li class="listitem">
     <p>
      For a long option that takes a value, separate the option
            name and the value by an
      <code class="literal">
       =
      </code>
      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:
      <code class="option">
       -hlocalhost
      </code>
      and
      <code class="option">
       -h
            localhost
      </code>
      are equivalent. An exception to this rule
            is the option for specifying your MySQL password. This
            option can be given in long form as
      <a class="link" href="connection-options.html#option_general_password">
       <code class="option">
        --password=
        <em class="replaceable">
         <code>
          pass_val
         </code>
        </em>
       </code>
      </a>
      or as
      <a class="link" href="connection-options.html#option_general_password">
       <code class="option">
        --password
       </code>
      </a>
      . In the
            latter case (with no password value given), the program
            interactively prompts you for the password. The password
            option also may be given in short form as
      <code class="option">
       -p
       <em class="replaceable">
        <code>
         pass_val
        </code>
       </em>
      </code>
      or as
      <code class="option">
       -p
      </code>
      . However, for the short form, if the
            password value is given, it must follow the option letter
            with
      <span class="emphasis">
       <em>
        no intervening space
       </em>
      </span>
      : 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:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa72940878"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token property">-ptest</span>
mysql <span class="token property">-p</span> test</code></pre>
     </div>
     <p>
      The first command instructs
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      to use
            a password value of
      <code class="literal">
       test
      </code>
      , but specifies
            no default database. The second instructs
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      to prompt for the password value
            and to use
      <code class="literal">
       test
      </code>
      as the default database.
     </p>
    </li>
    <li class="listitem">
     <p>
      Within option names, dash (
      <code class="literal">
       -
      </code>
      ) and
            underscore (
      <code class="literal">
       _
      </code>
      ) may be used
            interchangeably in most cases, although the leading dashes
      <span class="emphasis">
       <em>
        cannot
       </em>
      </span>
      be given as underscores. For
            example,
      <a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
       <code class="option">
        --skip-grant-tables
       </code>
      </a>
      and
      <a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
       <code class="option">
        --skip_grant_tables
       </code>
      </a>
      are equivalent.
     </p>
     <p>
      In this Manual, we use dashes in option names, except where
            underscores are significant. This is the case with, for
            example,
      <a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
       <code class="option">
        --log-bin
       </code>
      </a>
      and
      <a class="link" href="replication-options-binary-log.html#sysvar_log_bin">
       <code class="option">
        --log_bin
       </code>
      </a>
      , which are
            different options. We encourage you to do so as well.
     </p>
    </li>
    <li class="listitem">
     <p>
      The MySQL server has certain command options that may be
            specified only at startup, and a set of system variables,
            some of which may be set at startup, at runtime, or both.
            System variable names use underscores rather than dashes,
            and when referenced at runtime (for example, using
      <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
       <code class="literal">
        SET
       </code>
      </a>
      or
      <a class="link" href="select.html" title="15.2.13 SELECT Statement">
       <code class="literal">
        SELECT
       </code>
      </a>
      statements), must
            be written using underscores:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa79597969"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> general_log <span class="token operator">=</span> <span class="token keyword">ON</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token variable">@@GLOBAL.general_log</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      At server startup, the syntax for system variables is the
            same as for command options, so within variable names,
            dashes and underscores may be used interchangeably. For
            example,
      <a class="link" href="server-system-variables.html#sysvar_general_log">
       <code class="option">
        --general_log=ON
       </code>
      </a>
      and
      <a class="link" href="server-system-variables.html#sysvar_general_log">
       <code class="option">
        --general-log=ON
       </code>
      </a>
      are
            equivalent. (This is also true for system variables set
            within option files.)
     </p>
    </li>
    <li class="listitem">
     <p>
      For options that take a numeric value, the value can be
            given with a suffix of
      <code class="literal">
       K
      </code>
      ,
      <code class="literal">
       M
      </code>
      , or
      <code class="literal">
       G
      </code>
      to indicate a
            multiplier of 1024, 1024
      <sup>
       2
      </sup>
      or
            1024
      <sup>
       3
      </sup>
      . As of MySQL 8.0.14, a
            suffix can also be
      <code class="literal">
       T
      </code>
      ,
      <code class="literal">
       P
      </code>
      , and
      <code class="literal">
       E
      </code>
      to indicate a
            multiplier of 1024
      <sup>
       4
      </sup>
      ,
            1024
      <sup>
       5
      </sup>
      or
            1024
      <sup>
       6
      </sup>
      . Suffix letters can be
            uppercase or lowercase.
     </p>
     <p>
      For example, the following command tells
      <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
       <span class="command">
        <strong>
         mysqladmin
        </strong>
       </span>
      </a>
      to ping the server 1024 times,
            sleeping 10 seconds between each ping:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa79298565"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqladmin <span class="token constant">--count</span><span class="token attr-value"><span class="token punctuation">=</span>1K</span> <span class="token constant">--sleep</span><span class="token attr-value"><span class="token punctuation">=</span>10</span> ping</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      When specifying file names as option values, avoid the use
            of the
      <code class="literal">
       ~
      </code>
      shell metacharacter. It might
            not be interpreted as you expect.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Option values that contain spaces must be quoted when given on
        the command line. For example, the
   <a class="link" href="mysql-command-options.html#option_mysql_execute">
    <code class="option">
     --execute
    </code>
   </a>
   (or
   <code class="option">
    -e
   </code>
   )
        option can be used with
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   to pass one or
        more semicolon-separated SQL statements to the server. When this
        option is used,
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   executes the statements
        in the option value and exits. The statements must be enclosed
        by quotation marks. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa89158189"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysql</span> <span class="token property">-u</span> root <span class="token property">-p</span> <span class="token property">-e</span> <span class="token atrule">"SELECT VERSION();SELECT NOW()"</span>
Enter password<span class="token punctuation">:</span> ******
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> VERSION()  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 8.0.19     <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NOW()               <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2019<span class="token punctuation">-</span>09<span class="token punctuation">-</span>03 10:36:48 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
$&gt;</code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The long form (
    <a class="link" href="mysql-command-options.html#option_mysql_execute">
     <code class="option">
      --execute
     </code>
    </a>
    ) is
          followed by an equal sign (
    <code class="literal">
     =
    </code>
    ).
   </p>
  </div>
  <p>
   To use quoted values within a statement, you must either escape
        the inner quotation marks, or use a different type of quotation
        marks within the statement from those used to quote the
        statement itself. The capabilities of your command processor
        dictate your choices for whether you can use single or double
        quotation marks and the syntax for escaping quote characters.
        For example, if your command processor supports quoting with
        single or double quotation marks, you can use double quotation
        marks around the statement, and single quotation marks for any
        quoted values within the statement.
  </p>
 </div>
 <br/>
</div>
