<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="error-log-rotation">
      </a>
      7.4.2.10 Error Log File Flushing and Renaming
     </h4>
    </div>
   </div>
  </div>
  <p>
   If you flush the error log using a
   <a class="link" href="flush.html#flush-error-logs">
    <code class="literal">
     FLUSH
        ERROR LOGS
    </code>
   </a>
   or
   <a class="link" href="flush.html#flush-logs">
    <code class="literal">
     FLUSH
        LOGS
    </code>
   </a>
   statement, or a
   <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
    <span class="command">
     <strong>
      mysqladmin
        flush-logs
     </strong>
    </span>
   </a>
   command, the server closes and reopens any
        error log file to which it is writing. To rename an error log
        file, do so manually before flushing. Flushing the logs then
        opens a new file with the original file name. For example,
        assuming a log file name of
   <code class="filename">
    <em class="replaceable">
     <code>
      host_name
     </code>
    </em>
    .err
   </code>
   ,
        use the following commands to rename the file and create a new
        one:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa18565814"><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">mv <em class="replaceable">host_name</em><span class="token punctuation">.</span>err <em class="replaceable">host_name</em><span class="token punctuation">.</span>err-old
mysqladmin flush-logs error
mv <em class="replaceable">host_name</em><span class="token punctuation">.</span>err-old <em class="replaceable">backup-directory</em></code></pre>
  </div>
  <p>
   On Windows, use
   <span class="command">
    <strong>
     rename
    </strong>
   </span>
   rather than
   <span class="command">
    <strong>
     mv
    </strong>
   </span>
   .
  </p>
  <p>
   If the location of the error log file is not writable by the
        server, the log-flushing operation fails to create a new log
        file. For example, on Linux, the server might write the error
        log to the
   <code class="filename">
    /var/log/mysqld.log
   </code>
   file, where
        the
   <code class="filename">
    /var/log
   </code>
   directory is owned by
   <code class="literal">
    root
   </code>
   and is not writable by
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   . For information about handling this
        case, see
   <a class="xref" href="log-file-maintenance.html" title="7.4.6 Server Log Maintenance">
    Section 7.4.6, “Server Log Maintenance”
   </a>
   .
  </p>
  <p>
   If the server is not writing to a named error log file, no error
        log file renaming occurs when the error log is flushed.
  </p>
 </div>
 <br/>
</div>
