<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="not-enough-file-handles">
      </a>
      B.3.2.16 File Not Found and Similar Errors
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045054193856">
  </a>
  <a class="indexterm" name="idm46045054192400">
  </a>
  <p>
   If you get
   <code class="literal">
    ERROR
          '
    <em class="replaceable">
     <code>
      file_name
     </code>
    </em>
    ' not found (errno:
          23)
   </code>
   ,
   <code class="literal">
    Can't open file:
    <em class="replaceable">
     <code>
      file_name
     </code>
    </em>
    (errno: 24)
   </code>
   , or
          any other error with
   <code class="literal">
    errno 23
   </code>
   or
   <code class="literal">
    errno 24
   </code>
   from MySQL, it means that you have
          not allocated enough file descriptors for the MySQL server.
          You can use the
   <a class="link" href="perror.html" title="6.8.1 perror — Display MySQL Error Message Information">
    <span class="command">
     <strong>
      perror
     </strong>
    </span>
   </a>
   utility to get a
          description of what the error number means:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa54150127"><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">perror</span> 23
OS error code  23<span class="token punctuation">:</span>  File table overflow
<span class="token prompt">$&gt; </span><span class="token command">perror</span> 24
OS error code  24<span class="token punctuation">:</span>  Too many open files
<span class="token prompt">$&gt; </span><span class="token command">perror</span> 11
OS error code  11<span class="token punctuation">:</span>  Resource temporarily unavailable</code></pre>
  </div>
  <p>
   The problem here is that
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   is trying
          to keep open too many files simultaneously. You can either
          tell
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   not to open so many files at
          once or increase the number of file descriptors available to
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   .
  </p>
  <p>
   To tell
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   to keep open fewer files at
          a time, you can make the table cache smaller by reducing the
          value of the
   <a class="link" href="server-system-variables.html#sysvar_table_open_cache">
    <code class="literal">
     table_open_cache
    </code>
   </a>
   system variable (the default value is 64). This may not
          entirely prevent running out of file descriptors because in
          some circumstances the server may attempt to extend the cache
          size temporarily, as described in
   <a class="xref" href="table-cache.html" title="10.4.3.1 How MySQL Opens and Closes Tables">
    Section 10.4.3.1, “How MySQL Opens and Closes Tables”
   </a>
   . Reducing the value of
   <a class="link" href="server-system-variables.html#sysvar_max_connections">
    <code class="literal">
     max_connections
    </code>
   </a>
   also reduces
          the number of open files (the default value is 100).
  </p>
  <a class="indexterm" name="idm46045054172912">
  </a>
  <p>
   To change the number of file descriptors available to
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   , you can use the
   <a class="link" href="mysqld-safe.html#option_mysqld_safe_open-files-limit">
    <code class="option">
     --open-files-limit
    </code>
   </a>
   option
          to
   <a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
    <span class="command">
     <strong>
      mysqld_safe
     </strong>
    </span>
   </a>
   or set the
   <a class="link" href="server-system-variables.html#sysvar_open_files_limit">
    <code class="literal">
     open_files_limit
    </code>
   </a>
   system
          variable. See
   <a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
    Section 7.1.8, “Server System Variables”
   </a>
   . The
          easiest way to set these values is to add an option to your
          option file. See
   <a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
    Section 6.2.2.2, “Using Option Files”
   </a>
   . If you have
          an old version of
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   that does not
          support setting the open files limit, you can edit the
   <a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
    <span class="command">
     <strong>
      mysqld_safe
     </strong>
    </span>
   </a>
   script. There is a
          commented-out line
   <span class="command">
    <strong>
     ulimit -n 256
    </strong>
   </span>
   in the
          script. You can remove the
   <code class="literal">
    #
   </code>
   character to
          uncomment this line, and change the number
   <code class="literal">
    256
   </code>
   to set the number of file descriptors
          to be made available to
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   .
  </p>
  <p>
   <a class="link" href="mysqld-safe.html#option_mysqld_safe_open-files-limit">
    <code class="option">
     --open-files-limit
    </code>
   </a>
   and
   <span class="command">
    <strong>
     ulimit
    </strong>
   </span>
   can increase the number of file
          descriptors, but only up to the limit imposed by the operating
          system. There is also a
   <span class="quote">
    “
    <span class="quote">
     hard
    </span>
    ”
   </span>
   limit that can be
          overridden only if you start
   <a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
    <span class="command">
     <strong>
      mysqld_safe
     </strong>
    </span>
   </a>
   or
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   as
   <code class="literal">
    root
   </code>
   (just
          remember that you also need to start the server with the
   <a class="link" href="server-options.html#option_mysqld_user">
    <code class="option">
     --user
    </code>
   </a>
   option in this case so
          that it does not continue to run as
   <code class="literal">
    root
   </code>
   after it starts up). If you need to increase the operating
          system limit on the number of file descriptors available to
          each process, consult the documentation for your system.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    If you run the
    <span class="command">
     <strong>
      tcsh
     </strong>
    </span>
    shell,
    <span class="command">
     <strong>
      ulimit
     </strong>
    </span>
    does not work!
    <span class="command">
     <strong>
      tcsh
     </strong>
    </span>
    also reports incorrect values when
            you ask for the current limits. In this case, you should
            start
    <a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
     <span class="command">
      <strong>
       mysqld_safe
      </strong>
     </span>
    </a>
    using
    <span class="command">
     <strong>
      sh
     </strong>
    </span>
    .
   </p>
  </div>
 </div>
 <br/>
</div>
