<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="mysql-commands">
      </a>
      6.5.1.2 mysql Client Commands
     </h4>
    </div>
   </div>
  </div>
  <p>
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   sends each SQL statement that you issue
        to the server to be executed. There is also a set of commands
        that
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   itself interprets. For a list of
        these commands, type
   <code class="literal">
    help
   </code>
   or
   <code class="literal">
    \h
   </code>
   at the
   <code class="literal">
    mysql&gt;
   </code>
   prompt:
  </p>
  <a class="indexterm" name="idm46045317917632">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-none"><div class="docs-select-all right" id="sa36906371"><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-none">mysql&gt; help

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given
               outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing
               binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.
query_attributes Sets string parameters (name1 value1 name2 value2 ...)
for the next query to pick up.
ssl_session_data_print Serializes the current SSL session data to stdout 
or file.

For server side help, type 'help contents'</code></pre>
  </div>
  <p>
   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 invoked with the
   <a class="link" href="mysql-command-options.html#option_mysql_binary-mode">
    <code class="option">
     --binary-mode
    </code>
   </a>
   option, all
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   commands are disabled except
   <code class="literal">
    charset
   </code>
   and
   <code class="literal">
    delimiter
   </code>
   in
        noninteractive mode (for input piped to
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   or loaded using the
   <code class="literal">
    source
   </code>
   command).
  </p>
  <p>
   Each command has both a long and short form. The long form is
        not case-sensitive; the short form is. The long form can be
        followed by an optional semicolon terminator, but the short form
        should not.
  </p>
  <p>
   The use of short-form commands within multiple-line
   <code class="literal">
    /*
        ... */
   </code>
   comments is not supported. Short-form commands
        do work within single-line
   <code class="literal">
    /*! ... */
   </code>
   version
        comments, as do
   <code class="literal">
    /*+ ... */
   </code>
   optimizer-hint
        comments, which are stored in object definitions. If there is a
        concern that optimizer-hint comments may be stored in object
        definitions so that dump files when reloaded with
   <code class="literal">
    mysql
   </code>
   would result in execution of such
        commands, either invoke
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   with the
   <a class="link" href="mysql-command-options.html#option_mysql_binary-mode">
    <code class="option">
     --binary-mode
    </code>
   </a>
   option or use a
        reload client other than
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317894480">
      </a>
      <a class="indexterm" name="idm46045317892992">
      </a>
      <code class="literal">
       help [
       <em class="replaceable">
        <code>
         arg
        </code>
       </em>
       ]
      </code>
      ,
      <code class="literal">
       \h [
       <em class="replaceable">
        <code>
         arg
        </code>
       </em>
       ]
      </code>
      ,
      <code class="literal">
       \? [
       <em class="replaceable">
        <code>
         arg
        </code>
       </em>
       ]
      </code>
      ,
      <code class="literal">
       ? [
       <em class="replaceable">
        <code>
         arg
        </code>
       </em>
       ]
      </code>
     </p>
     <p>
      Display a help message listing the available
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      commands.
     </p>
     <p>
      If you provide an argument to the
      <code class="literal">
       help
      </code>
      command,
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      uses it as a search string
            to access server-side help from the contents of the MySQL
            Reference Manual. For more information, see
      <a class="xref" href="mysql-server-side-help.html" title="6.5.1.4 mysql Client Server-Side Help">
       Section 6.5.1.4, “mysql Client Server-Side Help”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317881296">
      </a>
      <a class="indexterm" name="idm46045317879808">
      </a>
      <code class="literal">
       charset
       <em class="replaceable">
        <code>
         charset_name
        </code>
       </em>
      </code>
      ,
      <code class="literal">
       \C
       <em class="replaceable">
        <code>
         charset_name
        </code>
       </em>
      </code>
     </p>
     <p>
      Change the default character set and issue a
      <a class="link" href="set-names.html" title="15.7.6.3 SET NAMES Statement">
       <code class="literal">
        SET NAMES
       </code>
      </a>
      statement. This
            enables the character set to remain synchronized on the
            client and server 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 run with
            auto-reconnect enabled (which is not recommended), because
            the specified character set is used for reconnects.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317872288">
      </a>
      <a class="indexterm" name="idm46045317870800">
      </a>
      <code class="literal">
       clear
      </code>
      ,
      <code class="literal">
       \c
      </code>
     </p>
     <p>
      Clear the current input. Use this if you change your mind
            about executing the statement that you are entering.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317866656">
      </a>
      <a class="indexterm" name="idm46045317865168">
      </a>
      <code class="literal">
       connect [
       <em class="replaceable">
        <code>
         db_name
        </code>
       </em>
       [
       <em class="replaceable">
        <code>
         host_name
        </code>
       </em>
       ]]
      </code>
      ,
      <code class="literal">
       \r [
       <em class="replaceable">
        <code>
         db_name
        </code>
       </em>
       [
       <em class="replaceable">
        <code>
         host_name
        </code>
       </em>
       ]]
      </code>
     </p>
     <p>
      Reconnect to the server. The optional database name and host
            name arguments may be given to specify the default database
            or the host where the server is running. If omitted, the
            current values are used.
     </p>
     <p>
      If the
      <code class="literal">
       connect
      </code>
      command specifies a host
            name argument, that host takes precedence over any
      <a class="link" href="mysql-command-options.html#option_mysql_dns-srv-name">
       <code class="option">
        --dns-srv-name
       </code>
      </a>
      option given at
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      startup to specify a DNS SRV
            record.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317855568">
      </a>
      <a class="indexterm" name="idm46045317854080">
      </a>
      <code class="literal">
       delimiter
       <em class="replaceable">
        <code>
         str
        </code>
       </em>
      </code>
      ,
      <code class="literal">
       \d
       <em class="replaceable">
        <code>
         str
        </code>
       </em>
      </code>
     </p>
     <p>
      Change the string that
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      interprets
            as the separator between SQL statements. The default is the
            semicolon character (
      <code class="literal">
       ;
      </code>
      ).
     </p>
     <p>
      The delimiter string can be specified as an unquoted or
            quoted argument on the
      <code class="literal">
       delimiter
      </code>
      command
            line. Quoting can be done with either single quote
            (
      <code class="literal">
       '
      </code>
      ), double quote (
      <code class="literal">
       "
      </code>
      ),
            or backtick (
      <code class="literal">
       `
      </code>
      ) characters. To include a
            quote within a quoted string, either quote the string with a
            different quote character or escape the quote with a
            backslash (
      <code class="literal">
       \
      </code>
      ) character. Backslash should
            be avoided outside of quoted strings because it is the
            escape character for MySQL. For an unquoted argument, the
            delimiter is read up to the first space or end of line. For
            a quoted argument, the delimiter is read up to the matching
            quote on the line.
     </p>
     <p>
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      interprets instances of the
            delimiter string as a statement delimiter anywhere it
            occurs, except within quoted strings. Be careful about
            defining a delimiter that might occur within other words.
            For example, if you define the delimiter as
      <code class="literal">
       X
      </code>
      , it is not possible to use the word
      <code class="literal">
       INDEX
      </code>
      in statements.
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      interprets this as
      <code class="literal">
       INDE
      </code>
      followed by the delimiter
      <code class="literal">
       X
      </code>
      .
     </p>
     <p>
      When the delimiter recognized by
      <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
            set to something other than the default of
      <code class="literal">
       ;
      </code>
      , instances of that character are sent
            to the server without interpretation. However, the server
            itself still interprets
      <code class="literal">
       ;
      </code>
      as a statement
            delimiter and processes statements accordingly. This
            behavior on the server side comes into play for
            multiple-statement execution (see
      <a class="ulink" href="/doc/c-api/8.4/en/c-api-multiple-queries.html" target="_top">
       Multiple Statement Execution Support
      </a>
      ), and for parsing
            the body of stored procedures and functions, triggers, and
            events (see
      <a class="xref" href="stored-programs-defining.html" title="27.1 Defining Stored Programs">
       Section 27.1, “Defining Stored Programs”
      </a>
      ).
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317831664">
      </a>
      <a class="indexterm" name="idm46045317830176">
      </a>
      <code class="literal">
       edit
      </code>
      ,
      <code class="literal">
       \e
      </code>
     </p>
     <p>
      Edit the current input statement.
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      checks the values of the
      <code class="literal">
       EDITOR
      </code>
      and
      <code class="literal">
       VISUAL
      </code>
      environment variables to determine
            which editor to use. The default editor is
      <span class="command">
       <strong>
        vi
       </strong>
      </span>
      if neither variable is set.
     </p>
     <p>
      The
      <code class="literal">
       edit
      </code>
      command works only in Unix.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317821504">
      </a>
      <a class="indexterm" name="idm46045317820016">
      </a>
      <code class="literal">
       ego
      </code>
      ,
      <code class="literal">
       \G
      </code>
     </p>
     <p>
      Send the current statement to the server to be executed and
            display the result using vertical format.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317815856">
      </a>
      <a class="indexterm" name="idm46045317814368">
      </a>
      <code class="literal">
       exit
      </code>
      ,
      <code class="literal">
       \q
      </code>
     </p>
     <p>
      Exit
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317809120">
      </a>
      <a class="indexterm" name="idm46045317807632">
      </a>
      <code class="literal">
       go
      </code>
      ,
      <code class="literal">
       \g
      </code>
     </p>
     <p>
      Send the current statement to the server to be executed.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317803584">
      </a>
      <a class="indexterm" name="idm46045317802096">
      </a>
      <code class="literal">
       nopager
      </code>
      ,
      <code class="literal">
       \n
      </code>
     </p>
     <p>
      Disable output paging. See the description for
      <code class="literal">
       pager
      </code>
      .
     </p>
     <p>
      The
      <code class="literal">
       nopager
      </code>
      command works only in Unix.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317796144">
      </a>
      <a class="indexterm" name="idm46045317794656">
      </a>
      <code class="literal">
       notee
      </code>
      ,
      <code class="literal">
       \t
      </code>
     </p>
     <p>
      Disable output copying to the tee file. See the description
            for
      <code class="literal">
       tee
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317789824">
      </a>
      <a class="indexterm" name="idm46045317788336">
      </a>
      <code class="literal">
       nowarning
      </code>
      ,
      <code class="literal">
       \w
      </code>
     </p>
     <p>
      Disable display of warnings after each statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317784208">
      </a>
      <a class="indexterm" name="idm46045317782720">
      </a>
      <code class="literal">
       pager
            [
       <em class="replaceable">
        <code>
         command
        </code>
       </em>
       ]
      </code>
      ,
      <code class="literal">
       \P
            [
       <em class="replaceable">
        <code>
         command
        </code>
       </em>
       ]
      </code>
     </p>
     <p>
      Enable output paging. By using the
      <a class="link" href="mysql-command-options.html#option_mysql_pager">
       <code class="option">
        --pager
       </code>
      </a>
      option when you invoke
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      , it is possible to browse or search
            query results in interactive mode with Unix programs such as
      <span class="command">
       <strong>
        less
       </strong>
      </span>
      ,
      <span class="command">
       <strong>
        more
       </strong>
      </span>
      , or any
            other similar program. If you specify no value for the
            option,
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      checks the value of the
      <code class="literal">
       PAGER
      </code>
      environment variable and sets the
            pager to that. Pager functionality works only in interactive
            mode.
     </p>
     <p>
      Output paging can be enabled interactively with the
      <code class="literal">
       pager
      </code>
      command and disabled with
      <code class="literal">
       nopager
      </code>
      . The command takes an optional
            argument; if given, the paging program is set to that. With
            no argument, the pager is set to the pager that was set on
            the command line, or
      <code class="literal">
       stdout
      </code>
      if no pager
            was specified.
     </p>
     <p>
      Output paging works only in Unix because it uses the
      <code class="literal">
       popen()
      </code>
      function, which does not exist on
            Windows. For Windows, the
      <code class="literal">
       tee
      </code>
      option can
            be used instead to save query output, although it is not as
            convenient as
      <code class="literal">
       pager
      </code>
      for browsing output
            in some situations.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317766192">
      </a>
      <a class="indexterm" name="idm46045317764704">
      </a>
      <code class="literal">
       print
      </code>
      ,
      <code class="literal">
       \p
      </code>
     </p>
     <p>
      Print the current input statement without executing it.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317760576">
      </a>
      <a class="indexterm" name="idm46045317759088">
      </a>
      <code class="literal">
       prompt [
       <em class="replaceable">
        <code>
         str
        </code>
       </em>
       ]
      </code>
      ,
      <code class="literal">
       \R [
       <em class="replaceable">
        <code>
         str
        </code>
       </em>
       ]
      </code>
     </p>
     <p>
      Reconfigure 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>
      prompt to the given
            string. The special character sequences that can be used in
            the prompt are described later in this section.
     </p>
     <p>
      If you specify the
      <code class="literal">
       prompt
      </code>
      command with no
            argument,
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      resets the prompt to the
            default of
      <code class="literal">
       mysql&gt;
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317749696">
      </a>
      <a class="indexterm" name="idm46045317748192">
      </a>
      <code class="literal">
       query_attributes
       <em class="replaceable">
        <code>
         name
        </code>
       </em>
       <em class="replaceable">
        <code>
         value
        </code>
       </em>
       [
       <em class="replaceable">
        <code>
         name
        </code>
       </em>
       <em class="replaceable">
        <code>
         value
        </code>
       </em>
       ...]
      </code>
     </p>
     <p>
      Define query attributes that apply to the next query sent to
            the server. For discussion of the purpose and use of query
            attributes, see
      <a class="xref" href="query-attributes.html" title="11.6 Query Attributes">
       Section 11.6, “Query Attributes”
      </a>
      .
     </p>
     <p>
      The
      <code class="literal">
       query_attributes
      </code>
      command follows
            these rules:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         The format and quoting rules for attribute names and
                values are the same as for the
         <code class="literal">
          delimiter
         </code>
         command.
        </p>
       </li>
       <li class="listitem">
        <p>
         The command permits up to 32 attribute name/value pairs.
                Names and values may be up to 1024 characters long. If a
                name is given without a value, an error occurs.
        </p>
       </li>
       <li class="listitem">
        <p>
         If multiple
         <code class="literal">
          query_attributes
         </code>
         commands
                are issued prior to query execution, only the last
                command applies. After sending the query,
         <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
          <span class="command">
           <strong>
            mysql
           </strong>
          </span>
         </a>
         clears the attribute set.
        </p>
       </li>
       <li class="listitem">
        <p>
         If multiple attributes are defined with the same name,
                attempts to retrieve the attribute value have an
                undefined result.
        </p>
       </li>
       <li class="listitem">
        <p>
         An attribute defined with an empty name cannot be
                retrieved by name.
        </p>
       </li>
       <li class="listitem">
        <p>
         If a reconnect occurs while
         <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 query,
         <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
          <span class="command">
           <strong>
            mysql
           </strong>
          </span>
         </a>
         restores
                the attributes after reconnecting so the query can be
                executed again with the same attributes.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317728752">
      </a>
      <a class="indexterm" name="idm46045317727264">
      </a>
      <code class="literal">
       quit
      </code>
      ,
      <code class="literal">
       \q
      </code>
     </p>
     <p>
      Exit
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317722016">
      </a>
      <a class="indexterm" name="idm46045317720528">
      </a>
      <code class="literal">
       rehash
      </code>
      ,
      <code class="literal">
       \#
      </code>
     </p>
     <p>
      Rebuild the completion hash that enables database, table,
            and column name completion while you are entering
            statements. (See the description for the
      <a class="link" href="mysql-command-options.html#option_mysql_auto-rehash">
       <code class="option">
        --auto-rehash
       </code>
      </a>
      option.)
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317715296">
      </a>
      <a class="indexterm" name="idm46045317713808">
      </a>
      <code class="literal">
       resetconnection
      </code>
      ,
      <code class="literal">
       \x
      </code>
     </p>
     <p>
      Reset the connection to clear the session state. This
            includes clearing any current query attributes defined using
            the
      <code class="literal">
       query_attributes
      </code>
      command.
     </p>
     <p>
      Resetting a connection has effects similar to
      <a class="ulink" href="/doc/c-api/8.4/en/mysql-change-user.html" target="_top">
       <code class="literal">
        mysql_change_user()
       </code>
      </a>
      or an
            auto-reconnect except that the connection is not closed and
            reopened, and re-authentication is not done. See
      <a class="ulink" href="/doc/c-api/8.4/en/mysql-change-user.html" target="_top">
       mysql_change_user()
      </a>
      , and
      <a class="ulink" href="/doc/c-api/8.4/en/c-api-auto-reconnect.html" target="_top">
       Automatic Reconnection Control
      </a>
      .
     </p>
     <p>
      This example shows how
      <code class="literal">
       resetconnection
      </code>
      clears a value maintained in the session state:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa71939571"><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 prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LAST_INSERT_ID</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><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 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> LAST_INSERT_ID(3) <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>
<span class="token output"><span class="token punctuation">|</span>                 3 <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>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LAST_INSERT_ID</span><span class="token punctuation">(</span><span class="token punctuation">)</span><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 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> LAST_INSERT_ID() <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>
<span class="token output"><span class="token punctuation">|</span>                3 <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>

<span class="token prompt">mysql&gt;</span> resetconnection<span class="token punctuation">;</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LAST_INSERT_ID</span><span class="token punctuation">(</span><span class="token punctuation">)</span><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 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> LAST_INSERT_ID() <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>
<span class="token output"><span class="token punctuation">|</span>                0 <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></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317700016">
      </a>
      <a class="indexterm" name="idm46045317698528">
      </a>
      <code class="literal">
       source
       <em class="replaceable">
        <code>
         file_name
        </code>
       </em>
      </code>
      ,
      <code class="literal">
       \.
       <em class="replaceable">
        <code>
         file_name
        </code>
       </em>
      </code>
     </p>
     <p>
      Read the named file and executes the statements contained
            therein. On Windows, specify path name separators as
      <code class="literal">
       /
      </code>
      or
      <code class="literal">
       \\
      </code>
      .
     </p>
     <p>
      Quote characters are taken as part of the file name itself.
            For best results, the name should not include space
            characters.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317691824">
      </a>
      <a class="indexterm" name="idm46045317690320">
      </a>
      <code class="literal">
       ssl_session_data_print
            [
       <em class="replaceable">
        <code>
         file_name
        </code>
       </em>
       ]
      </code>
     </p>
     <p>
      Fetches, serializes, and optionally stores the session data
            of a successful connection. The optional file name and
            arguments may be given to specify the file to store
            serialized session data. If omitted, the session data is
            printed to
      <code class="literal">
       stdout
      </code>
      .
     </p>
     <p>
      If the MySQL session is configured for reuse, session data
            from the file is deserialized and supplied to the
      <code class="literal">
       connect
      </code>
      command to reconnect. When the
            session is reused successfully, the
      <code class="literal">
       status
      </code>
      command contains a row showing
      <code class="literal">
       SSL session reused: true
      </code>
      while the client
            remains reconnected to the server.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317682608">
      </a>
      <a class="indexterm" name="idm46045317681120">
      </a>
      <code class="literal">
       status
      </code>
      ,
      <code class="literal">
       \s
      </code>
     </p>
     <p>
      Provide status information about the connection and the
            server you are using. If you are running with
      <a class="link" href="mysql-command-options.html#option_mysql_safe-updates">
       <code class="option">
        --safe-updates
       </code>
      </a>
      enabled,
      <code class="literal">
       status
      </code>
      also prints the values for 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>
      variables that affect your queries.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317673968">
      </a>
      <a class="indexterm" name="idm46045317672480">
      </a>
      <code class="literal">
       system
       <em class="replaceable">
        <code>
         command
        </code>
       </em>
      </code>
      ,
      <code class="literal">
       \!
       <em class="replaceable">
        <code>
         command
        </code>
       </em>
      </code>
     </p>
     <p>
      Execute the given command using your default command
            interpreter.
     </p>
     <p>
      In MySQL 8.4.3 and later, this command can be disabled by
            starting the client with
      <a class="link" href="mysql-command-options.html#option_mysql_system-command">
       <code class="option">
        --system-command=OFF
       </code>
      </a>
      or
      <a class="link" href="mysql-command-options.html#option_mysql_skip-system-command">
       <code class="option">
        --skip-system-command
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317665216">
      </a>
      <a class="indexterm" name="idm46045317663728">
      </a>
      <code class="literal">
       tee
            [
       <em class="replaceable">
        <code>
         file_name
        </code>
       </em>
       ]
      </code>
      ,
      <code class="literal">
       \T [
       <em class="replaceable">
        <code>
         file_name
        </code>
       </em>
       ]
      </code>
     </p>
     <p>
      By using the
      <a class="link" href="mysql-command-options.html#option_mysql_tee">
       <code class="option">
        --tee
       </code>
      </a>
      option when
            you invoke
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      , you can log statements
            and their output. All the data displayed on the screen is
            appended into a given file. This can be very useful for
            debugging purposes also.
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      flushes
            results to the file after each statement, just before it
            prints its next prompt. Tee functionality works only in
            interactive mode.
     </p>
     <p>
      You can enable this feature interactively with the
      <code class="literal">
       tee
      </code>
      command. Without a parameter, the
            previous file is used. The
      <code class="literal">
       tee
      </code>
      file can
            be disabled with the
      <code class="literal">
       notee
      </code>
      command.
            Executing
      <code class="literal">
       tee
      </code>
      again re-enables logging.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317651648">
      </a>
      <a class="indexterm" name="idm46045317650160">
      </a>
      <code class="literal">
       use
       <em class="replaceable">
        <code>
         db_name
        </code>
       </em>
      </code>
      ,
      <code class="literal">
       \u
       <em class="replaceable">
        <code>
         db_name
        </code>
       </em>
      </code>
     </p>
     <p>
      Use
      <em class="replaceable">
       <code>
        db_name
       </code>
      </em>
      as the default
            database.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045317645008">
      </a>
      <a class="indexterm" name="idm46045317643520">
      </a>
      <code class="literal">
       warnings
      </code>
      ,
      <code class="literal">
       \W
      </code>
     </p>
     <p>
      Enable display of warnings after each statement (if there
            are any).
     </p>
    </li>
   </ul>
  </div>
  <p>
   Here are a few tips about the
   <code class="literal">
    pager
   </code>
   command:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      You can use it to write to a file and the results go only to
            the file:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa92762626"><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 prompt">mysql&gt;</span> pager cat <span class="token operator">&gt;</span> <span class="token operator">/</span>tmp<span class="token operator">/</span>log<span class="token punctuation">.</span>txt</code></pre>
     </div>
     <p>
      You can also pass any options for the program that you want
            to use as your pager:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa98188516"><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 prompt">mysql&gt;</span> pager <span class="token keyword">less</span> <span class="token operator">-</span>n <span class="token operator">-</span>i <span class="token operator">-</span>S</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      In the preceding example, note the
      <code class="option">
       -S
      </code>
      option. You may find it very useful for browsing wide query
            results. Sometimes a very wide result set is difficult to
            read on the screen. The
      <code class="option">
       -S
      </code>
      option to
      <span class="command">
       <strong>
        less
       </strong>
      </span>
      can make the result set much more
            readable because you can scroll it horizontally using the
            left-arrow and right-arrow keys. You can also use
      <code class="option">
       -S
      </code>
      interactively within
      <span class="command">
       <strong>
        less
       </strong>
      </span>
      to switch the horizontal-browse mode
            on and off. For more information, read the
      <span class="command">
       <strong>
        less
       </strong>
      </span>
      manual page:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa39740461"><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">man less</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="option">
       -F
      </code>
      and
      <code class="option">
       -X
      </code>
      options may
            be used with
      <span class="command">
       <strong>
        less
       </strong>
      </span>
      to cause it to exit if
            output fits on one screen, which is convenient when no
            scrolling is necessary:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa47109329"><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 prompt">mysql&gt;</span> pager <span class="token keyword">less</span> <span class="token operator">-</span>n <span class="token operator">-</span>i <span class="token operator">-</span>S <span class="token operator">-</span>F <span class="token operator">-</span>X</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      You can specify very complex pager commands for handling
            query output:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa98536622"><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 prompt">mysql&gt;</span> pager cat <span class="token operator">|</span> tee <span class="token operator">/</span>dr1<span class="token operator">/</span>tmp<span class="token operator">/</span>res<span class="token punctuation">.</span>txt \
          <span class="token operator">|</span> tee <span class="token operator">/</span>dr2<span class="token operator">/</span>tmp<span class="token operator">/</span>res2<span class="token punctuation">.</span>txt <span class="token operator">|</span> <span class="token keyword">less</span> <span class="token operator">-</span>n <span class="token operator">-</span>i <span class="token operator">-</span>S</code></pre>
     </div>
     <p>
      In this example, the command would send query results to two
            files in two different directories on two different file
            systems mounted on
      <code class="filename">
       /dr1
      </code>
      and
      <code class="filename">
       /dr2
      </code>
      , yet still display the results
            onscreen using
      <span class="command">
       <strong>
        less
       </strong>
      </span>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   You can also combine the
   <code class="literal">
    tee
   </code>
   and
   <code class="literal">
    pager
   </code>
   functions. Have a
   <code class="literal">
    tee
   </code>
   file enabled and
   <code class="literal">
    pager
   </code>
   set to
   <span class="command">
    <strong>
     less
    </strong>
   </span>
   , and you are able to browse the
        results using the
   <span class="command">
    <strong>
     less
    </strong>
   </span>
   program and still have
        everything appended into a file the same time. The difference
        between the Unix
   <code class="literal">
    tee
   </code>
   used with the
   <code class="literal">
    pager
   </code>
   command and 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>
   built-in
   <code class="literal">
    tee
   </code>
   command
        is that the built-in
   <code class="literal">
    tee
   </code>
   works even if you do
        not have the Unix
   <span class="command">
    <strong>
     tee
    </strong>
   </span>
   available. The built-in
   <code class="literal">
    tee
   </code>
   also logs everything that is printed on
        the screen, whereas the Unix
   <span class="command">
    <strong>
     tee
    </strong>
   </span>
   used with
   <code class="literal">
    pager
   </code>
   does not log quite that much.
        Additionally,
   <code class="literal">
    tee
   </code>
   file logging can be turned
        on and off interactively from within
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   .
        This is useful when you want to log some queries to a file, but
        not others.
  </p>
  <a class="indexterm" name="idm46045317603792">
  </a>
  <p>
   The
   <code class="literal">
    prompt
   </code>
   command reconfigures the default
   <code class="literal">
    mysql&gt;
   </code>
   prompt. The string for defining the
        prompt can contain the following special sequences.
  </p>
  <div class="informaltable">
   <table summary="prompt command options that are used to configure the mysql&gt; prompt.">
    <colgroup>
     <col style="width: 15%"/>
     <col style="width: 75%"/>
    </colgroup>
    <thead>
     <tr>
      <th>
       Option
      </th>
      <th>
       Description
      </th>
     </tr>
    </thead>
    <tbody>
     <tr>
      <td>
       <code class="literal">
        \C
       </code>
      </td>
      <td>
       The current connection identifier
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \c
       </code>
      </td>
      <td>
       A counter that increments for each statement you issue
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \D
       </code>
      </td>
      <td>
       The full current date
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \d
       </code>
      </td>
      <td>
       The default database
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \h
       </code>
      </td>
      <td>
       The server host
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \l
       </code>
      </td>
      <td>
       The current delimiter
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \m
       </code>
      </td>
      <td>
       Minutes of the current time
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \n
       </code>
      </td>
      <td>
       A newline character
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \O
       </code>
      </td>
      <td>
       The current month in three-letter format (Jan, Feb, …)
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \o
       </code>
      </td>
      <td>
       The current month in numeric format
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \P
       </code>
      </td>
      <td>
       am/pm
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \p
       </code>
      </td>
      <td>
       The current TCP/IP port or socket file
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \R
       </code>
      </td>
      <td>
       The current time, in 24-hour military time (0–23)
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \r
       </code>
      </td>
      <td>
       The current time, standard 12-hour time (1–12)
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \S
       </code>
      </td>
      <td>
       Semicolon
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \s
       </code>
      </td>
      <td>
       Seconds of the current time
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \T
       </code>
      </td>
      <td>
       Print an asterisk (
       <code class="literal">
        *
       </code>
       ) if the current session is
              inside a transaction block
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \t
       </code>
      </td>
      <td>
       A tab character
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \U
       </code>
      </td>
      <td>
       <p>
        Your full
        <code class="literal">
         <em class="replaceable">
          <code>
           user_name
          </code>
         </em>
         @
         <em class="replaceable">
          <code>
           host_name
          </code>
         </em>
        </code>
        account name
       </p>
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \u
       </code>
      </td>
      <td>
       Your user name
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \v
       </code>
      </td>
      <td>
       The server version
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \w
       </code>
      </td>
      <td>
       The current day of the week in three-letter format (Mon, Tue, …)
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \Y
       </code>
      </td>
      <td>
       The current year, four digits
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \y
       </code>
      </td>
      <td>
       The current year, two digits
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \_
       </code>
      </td>
      <td>
       A space
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \
       </code>
      </td>
      <td>
       A space (a space follows the backslash)
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \'
       </code>
      </td>
      <td>
       Single quote
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \"
       </code>
      </td>
      <td>
       Double quote
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \\
       </code>
      </td>
      <td>
       A literal
       <code class="literal">
        \
       </code>
       backslash character
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        \
        <em class="replaceable">
         <code>
          x
         </code>
        </em>
       </code>
      </td>
      <td>
       <p>
        <em class="replaceable">
         <code>
          x
         </code>
        </em>
        , for any
        <span class="quote">
         “
         <span class="quote">
          <em class="replaceable">
           <code>
            x
           </code>
          </em>
         </span>
         ”
        </span>
        not listed
                above
       </p>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <div class="informaltable">
   <table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 590px;">
    <thead>
     <tr>
      <th style="width: 98.1094px;">
       Option
      </th>
      <th style="width: 490.547px;">
       Description
      </th>
     </tr>
    </thead>
   </table>
  </div>
  <p>
   You can set the prompt in several ways:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <span class="emphasis">
       <em>
        Use an environment variable.
       </em>
      </span>
      You can
            set the
      <code class="literal">
       MYSQL_PS1
      </code>
      environment variable to
            a prompt string. For example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa98774392"><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">export MYSQL_PS1=<span class="token atrule">"(\u@\h) [\d]&gt; "</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <span class="emphasis">
       <em>
        Use a command-line option.
       </em>
      </span>
      You can set
            the
      <a class="link" href="mysql-command-options.html#option_mysql_prompt">
       <code class="option">
        --prompt
       </code>
      </a>
      option on the
            command line to
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      . For example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa21611396"><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">--prompt</span>=<span class="token atrule">"(\u@\h) [\d]&gt; "</span>
<span class="token punctuation">(</span>user@host<span class="token punctuation">)</span> <span class="token punctuation">[</span>database<span class="token punctuation">]</span>&gt;</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <span class="emphasis">
       <em>
        Use an option file.
       </em>
      </span>
      You can set the
      <code class="literal">
       prompt
      </code>
      option in the
      <code class="literal">
       [mysql]
      </code>
      group of any MySQL option file,
            such as
      <code class="filename">
       /etc/my.cnf
      </code>
      or the
      <code class="filename">
       .my.cnf
      </code>
      file in your home directory.
            For example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa96201781"><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-ini"><span class="token selector">[mysql]</span>
<span class="token constant">prompt</span><span class="token attr-value"><span class="token punctuation">=</span>(\\u@\\h) [\\d]&gt;\\_</span></code></pre>
     </div>
     <p>
      In this example, note that the backslashes are doubled. If
            you set the prompt using the
      <code class="literal">
       prompt
      </code>
      option in an option file, it is advisable to double the
            backslashes when using the special prompt options. There is
            some overlap in the set of permissible prompt options and
            the set of special escape sequences that are recognized in
            option files. (The rules for escape sequences in option
            files are listed in
      <a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
       Section 6.2.2.2, “Using Option Files”
      </a>
      .) The
            overlap may cause you problems if you use single
            backslashes. For example,
      <code class="literal">
       \s
      </code>
      is
            interpreted as a space rather than as the current seconds
            value. The following example shows how to define a prompt
            within an option file to include the current time in
      <code class="literal">
       <em class="replaceable">
        <code>
         hh:mm:ss
        </code>
       </em>
       &gt;
      </code>
      format:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa23724366"><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-ini"><span class="token selector">[mysql]</span>
<span class="token constant">prompt</span><span class="token attr-value"><span class="token punctuation">=</span>"\\r:\\m:\\s&gt; "</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <span class="emphasis">
       <em>
        Set the prompt interactively.
       </em>
      </span>
      You can
            change your prompt interactively by using the
      <code class="literal">
       prompt
      </code>
      (or
      <code class="literal">
       \R
      </code>
      )
            command. For example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37341924"><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 prompt">mysql&gt;</span> prompt <span class="token punctuation">(</span>\u@\h<span class="token punctuation">)</span> <span class="token punctuation">[</span>\d<span class="token punctuation">]</span><span class="token operator">&gt;</span>\_
PROMPT <span class="token keyword">set</span> <span class="token keyword">to</span> <span class="token string">'(\u@\h) [\d]&gt;\_'</span>
<span class="token punctuation">(</span><span class="token keyword"><em class="replaceable">user</em></span><span class="token variable">@<em class="replaceable">host</em></span><span class="token punctuation">)</span> <span class="token punctuation">[</span><span class="token keyword"><em class="replaceable">database</em></span><span class="token punctuation">]</span><span class="token operator">&gt;</span>
<span class="token punctuation">(</span><span class="token keyword"><em class="replaceable">user</em></span><span class="token variable">@<em class="replaceable">host</em></span><span class="token punctuation">)</span> <span class="token punctuation">[</span><span class="token keyword"><em class="replaceable">database</em></span><span class="token punctuation">]</span><span class="token operator">&gt;</span> prompt
<span class="token keyword">Returning</span> <span class="token keyword">to</span> <span class="token keyword">default</span> PROMPT <span class="token keyword">of</span> mysql<span class="token operator">&gt;</span>
<span class="token prompt">mysql&gt;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
