<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="mysql">
      </a>
      6.5.1 mysql — The MySQL Command-Line Client
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="mysql-command-options.html">
       6.5.1.1 mysql Client Options
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="mysql-commands.html">
       6.5.1.2 mysql Client Commands
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="mysql-logging.html">
       6.5.1.3 mysql Client Logging
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="mysql-server-side-help.html">
       6.5.1.4 mysql Client Server-Side Help
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="mysql-batch-commands.html">
       6.5.1.5 Executing SQL Statements from a Text File
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="mysql-tips.html">
       6.5.1.6 mysql Client Tips
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045320189424">
  </a>
  <a class="indexterm" name="idm46045320188512">
  </a>
  <a class="indexterm" name="idm46045320187568">
  </a>
  <a class="indexterm" name="idm46045320186208">
  </a>
  <a class="indexterm" name="idm46045320184880">
  </a>
  <a class="indexterm" name="idm46045320183936">
  </a>
  <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>
   is a simple SQL shell with input line
        editing capabilities. It supports interactive and noninteractive
        use. When used interactively, query results are presented in an
        ASCII-table format. When used noninteractively (for example, as
        a filter), the result is presented in tab-separated format. The
        output format can be changed using command options.
  </p>
  <p>
   If you have problems due to insufficient memory for large result
        sets, use the
   <a class="link" href="mysql-command-options.html#option_mysql_quick">
    <code class="option">
     --quick
    </code>
   </a>
   option. This
        forces
   <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 retrieve results from the
        server a row at a time rather than retrieving the entire result
        set and buffering it in memory before displaying it. This is
        done by returning the result set using the
   <a class="ulink" href="/doc/c-api/8.4/en/mysql-use-result.html" target="_top">
    <code class="literal">
     mysql_use_result()
    </code>
   </a>
   C API
        function in the client/server library rather than
   <a class="ulink" href="/doc/c-api/8.4/en/mysql-store-result.html" target="_top">
    <code class="literal">
     mysql_store_result()
    </code>
   </a>
   .
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Alternatively, MySQL Shell offers access to the X DevAPI.
          For details, see
    <a class="ulink" href="/doc/mysql-shell/8.4/en/" target="_top">
     MySQL Shell 8.4
    </a>
    .
   </p>
  </div>
  <p>
   Using
   <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 very easy. Invoke it from the
        prompt of your command interpreter as follows:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa82751612"><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 <em class="replaceable">db_name</em></code></pre>
  </div>
  <p>
   Or:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa68282614"><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 constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">user_name</em></span> <span class="token property">--password</span> <em class="replaceable">db_name</em></code></pre>
  </div>
  <p>
   In this case, you'll need to enter your password in response to
        the prompt 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>
   displays:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa12974386"><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">Enter password<span class="token punctuation">:</span> <em class="replaceable">your_password</em></code></pre>
  </div>
  <p>
   Then type an SQL statement, end it with
   <code class="literal">
    ;
   </code>
   ,
   <code class="literal">
    \g
   </code>
   , or
   <code class="literal">
    \G
   </code>
   and press Enter.
  </p>
  <p>
   Typing
   <span class="keycap">
    <strong>
     Control+C
    </strong>
   </span>
   interrupts the current
        statement if there is one, or cancels any partial input line
        otherwise.
  </p>
  <a class="indexterm" name="idm46045320161488">
  </a>
  <a class="indexterm" name="idm46045320160000">
  </a>
  <p>
   You can execute SQL statements in a script file (batch file)
        like this:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa33882092"><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 <em class="replaceable">db_name</em> &lt; <em class="replaceable">script<span class="token punctuation">.</span>sql</em> &gt; <em class="replaceable">output<span class="token punctuation">.</span>tab</em></code></pre>
  </div>
  <p>
   On Unix, 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>
   client logs statements
        executed interactively to a history file. See
   <a class="xref" href="mysql-logging.html" title="6.5.1.3 mysql Client Logging">
    Section 6.5.1.3, “mysql Client Logging”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
