<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="shutdown">
      </a>
      15.7.8.9 SHUTDOWN Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045168232752">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa19301780"><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">SHUTDOWN</span></code></pre>
  </div>
  <p>
   This statement stops the MySQL server. It requires the
   <a class="link" href="privileges-provided.html#priv_shutdown">
    <code class="literal">
     SHUTDOWN
    </code>
   </a>
   privilege.
  </p>
  <p>
   <a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
    <code class="literal">
     SHUTDOWN
    </code>
   </a>
   provides an SQL-level
        interface to the same functionality available using the
   <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
    <span class="command">
     <strong>
      mysqladmin shutdown
     </strong>
    </span>
   </a>
   command. A successful
   <a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
    <code class="literal">
     SHUTDOWN
    </code>
   </a>
   sequence consists of
        checking the privileges, validating the arguments, and sending
        an OK packet to the client. Then the server is shut down.
  </p>
  <p>
   The
   <a class="link" href="server-status-variables.html#statvar_Com_xxx">
    <code class="literal">
     Com_shutdown
    </code>
   </a>
   status variable tracks the number of
   <a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
    <code class="literal">
     SHUTDOWN
    </code>
   </a>
   statements. Because
        status variables are initialized for each server startup and do
        not persist across restarts,
   <code class="literal">
    Com_shutdown
   </code>
   normally has a value of zero, but can be nonzero if
   <a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
    <code class="literal">
     SHUTDOWN
    </code>
   </a>
   statements were executed
        but failed.
  </p>
  <a class="indexterm" name="idm46045168216576">
  </a>
  <p>
   Another way to stop the server is to send it a
   <code class="literal">
    SIGTERM
   </code>
   signal, which can be done by
   <code class="literal">
    root
   </code>
   or the account that owns the server
        process.
   <code class="literal">
    SIGTERM
   </code>
   enables server shutdown to
        be performed without having to connect to the server. See
   <a class="xref" href="unix-signal-response.html" title="6.10 Unix Signal Handling in MySQL">
    Section 6.10, “Unix Signal Handling in MySQL”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
