<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="invoking-programs">
      </a>
      6.2.1 Invoking MySQL Programs
     </h3>
    </div>
   </div>
  </div>
  <p>
   To invoke a MySQL program from the command line (that is, from
      your shell or command prompt), enter the program name followed by
      any options or other arguments needed to instruct the program what
      you want it to do. The following commands show some sample program
      invocations.
   <code class="literal">
    $&gt;
   </code>
   represents the prompt for
      your command interpreter; it is not part of what you type. The
      particular prompt you see depends on your command interpreter.
      Typical prompts are
   <code class="literal">
    $
   </code>
   for
   <span class="command">
    <strong>
     sh
    </strong>
   </span>
   ,
   <span class="command">
    <strong>
     ksh
    </strong>
   </span>
   , or
   <span class="command">
    <strong>
     bash
    </strong>
   </span>
   ,
   <code class="literal">
    %
   </code>
   for
   <span class="command">
    <strong>
     csh
    </strong>
   </span>
   or
   <span class="command">
    <strong>
     tcsh
    </strong>
   </span>
   , and
   <code class="literal">
    C:\&gt;
   </code>
   for the Windows
   <span class="command">
    <strong>
     command.com
    </strong>
   </span>
   or
   <span class="command">
    <strong>
     cmd.exe
    </strong>
   </span>
   command interpreters.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa69550990"><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 constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>root</span> test
<span class="token prompt">$&gt; </span><span class="token command">mysqladmin</span> extended-status variables
<span class="token prompt">$&gt; </span><span class="token command">mysqlshow</span> <span class="token property">--help</span>
<span class="token prompt">$&gt; </span><span class="token command">mysqldump</span> <span class="token property">-u</span> root personnel</code></pre>
  </div>
  <p>
   Arguments that begin with a single or double dash
      (
   <code class="literal">
    -
   </code>
   ,
   <code class="literal">
    --
   </code>
   ) specify program
      options. Options typically indicate the type of connection a
      program should make to the server or affect its operational mode.
      Option syntax is described in
   <a class="xref" href="program-options.html" title="6.2.2 Specifying Program Options">
    Section 6.2.2, “Specifying Program Options”
   </a>
   .
  </p>
  <p>
   Nonoption arguments (arguments with no leading dash) provide
      additional information to the program. For example, the
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   program interprets the first nonoption
      argument as a database name, so the command
   <code class="literal">
    mysql
      --user=root test
   </code>
   indicates that you want to use the
   <code class="literal">
    test
   </code>
   database.
  </p>
  <p>
   Later sections that describe individual programs indicate which
      options a program supports and describe the meaning of any
      additional nonoption arguments.
  </p>
  <p>
   Some options are common to a number of programs. The most
      frequently used of these are the
   <a class="link" href="connection-options.html#option_general_host">
    <code class="option">
     --host
    </code>
   </a>
   (or
   <code class="option">
    -h
   </code>
   ),
   <a class="link" href="connection-options.html#option_general_user">
    <code class="option">
     --user
    </code>
   </a>
   (or
   <code class="option">
    -u
   </code>
   ),
      and
   <a class="link" href="connection-options.html#option_general_password">
    <code class="option">
     --password
    </code>
   </a>
   (or
   <code class="option">
    -p
   </code>
   ) options that specify connection parameters.
      They indicate the host where the MySQL server is running, and the
      user name and password of your MySQL account. All MySQL client
      programs understand these options; they enable you to specify
      which server to connect to and the account to use on that server.
      Other connection options are
   <a class="link" href="connection-options.html#option_general_port">
    <code class="option">
     --port
    </code>
   </a>
   (or
   <code class="option">
    -P
   </code>
   ) to
      specify a TCP/IP port number and
   <a class="link" href="connection-options.html#option_general_socket">
    <code class="option">
     --socket
    </code>
   </a>
   (or
   <code class="option">
    -S
   </code>
   )
      to specify a Unix socket file on Unix (or named-pipe name on
      Windows). For more information on options that specify connection
      options, see
   <a class="xref" href="connecting.html" title="6.2.4 Connecting to the MySQL Server Using Command Options">
    Section 6.2.4, “Connecting to the MySQL Server Using Command Options”
   </a>
   .
  </p>
  <a class="indexterm" name="idm46045324271232">
  </a>
  <a class="indexterm" name="idm46045324270144">
  </a>
  <p>
   You may find it necessary to invoke MySQL programs using the path
      name to the
   <code class="filename">
    bin
   </code>
   directory in which they are
      installed. This is likely to be the case if you get a
   <span class="quote">
    “
    <span class="quote">
     program not found
    </span>
    ”
   </span>
   error whenever you attempt to run
      a MySQL program from any directory other than the
   <code class="filename">
    bin
   </code>
   directory. To make it more convenient to
      use MySQL, you can add the path name of the
   <code class="filename">
    bin
   </code>
   directory to your
   <code class="literal">
    PATH
   </code>
   environment variable setting. That enables you to run a program by
      typing only its name, not its entire path name. For example, if
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   is installed in
   <code class="filename">
    /usr/local/mysql/bin
   </code>
   , you can run the program
      by invoking it as
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   , and it is not
      necessary to invoke it as
   <span class="command">
    <strong>
     /usr/local/mysql/bin/mysql
    </strong>
   </span>
   .
  </p>
  <p>
   Consult the documentation for your command interpreter for
      instructions on setting your
   <code class="literal">
    PATH
   </code>
   variable. The
      syntax for setting environment variables is interpreter-specific.
      (Some information is given in
   <a class="xref" href="setting-environment-variables.html" title="6.2.9 Setting Environment Variables">
    Section 6.2.9, “Setting Environment Variables”
   </a>
   .) After modifying
      your
   <code class="literal">
    PATH
   </code>
   setting, open a new console window on
      Windows or log in again on Unix so that the setting goes into
      effect.
  </p>
 </div>
 <br/>
</div>
