<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="starting-server-troubleshooting">
      </a>
      2.9.2.1 Troubleshooting Problems Starting the MySQL Server
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045326856192">
  </a>
  <a class="indexterm" name="idm46045326854704">
  </a>
  <a class="indexterm" name="idm46045326853216">
  </a>
  <a class="indexterm" name="idm46045326851728">
  </a>
  <p>
   This section provides troubleshooting suggestions for problems
        starting the server. For additional suggestions for Windows
        systems, see
   <a class="xref" href="windows-troubleshooting.html" title="2.3.4 Troubleshooting a Microsoft Windows MySQL Server Installation">
    Section 2.3.4, “Troubleshooting a Microsoft Windows MySQL Server Installation”
   </a>
   .
  </p>
  <p>
   If you have problems starting the server, here are some things
        to try:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Check the
      <a class="link" href="glossary.html#glos_error_log" title="error log">
       error log
      </a>
      to
            see why the server does not start. Log files are located in
            the
      <a class="link" href="glossary.html#glos_data_directory" title="data directory">
       data
            directory
      </a>
      (typically
      <code class="filename">
       C:\Program
            Files\MySQL\MySQL Server 8.4\data
      </code>
      on
            Windows,
      <code class="filename">
       /usr/local/mysql/data
      </code>
      for a
            Unix/Linux binary distribution, and
      <code class="filename">
       /usr/local/var
      </code>
      for a Unix/Linux source
            distribution). Look in the data directory for files with
            names of the form
      <code class="filename">
       <em class="replaceable">
        <code>
         host_name
        </code>
       </em>
       .err
      </code>
      and
      <code class="filename">
       <em class="replaceable">
        <code>
         host_name
        </code>
       </em>
       .log
      </code>
      ,
            where
      <em class="replaceable">
       <code>
        host_name
       </code>
      </em>
      is the name of
            your server host. Then examine the last few lines of these
            files. Use
      <code class="literal">
       tail
      </code>
      to display them:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa18422351"><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">tail</span> <em class="replaceable">host_name</em><span class="token punctuation">.</span>err
<span class="token prompt">$&gt; </span><span class="token command">tail</span> <em class="replaceable">host_name</em><span class="token punctuation">.</span>log</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Specify any special options needed by the storage engines
            you are using. You can create a
      <code class="filename">
       my.cnf
      </code>
      file and specify startup options for the engines that you
            plan to use. If you are going to use storage engines that
            support transactional tables (
      <code class="literal">
       InnoDB
      </code>
      ,
      <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
       <code class="literal">
        NDB
       </code>
      </a>
      ), be sure that you have
            them configured the way you want before starting the server.
            If you are using
      <code class="literal">
       InnoDB
      </code>
      tables, see
      <a class="xref" href="innodb-configuration.html" title="17.8 InnoDB Configuration">
       Section 17.8, “InnoDB Configuration”
      </a>
      for guidelines and
      <a class="xref" href="innodb-parameters.html" title="17.14 InnoDB Startup Options and System Variables">
       Section 17.14, “InnoDB Startup Options and System Variables”
      </a>
      for option syntax.
     </p>
     <p>
      Although storage engines use default values for options that
            you omit, Oracle recommends that you review the available
            options and specify explicit values for any options whose
            defaults are not appropriate for your installation.
     </p>
    </li>
    <li class="listitem">
     <p>
      Make sure that the server knows where to find the
      <a class="link" href="glossary.html#glos_data_directory" title="data directory">
       data directory
      </a>
      .
            The
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server uses this directory as
            its current directory. This is where it expects to find
            databases and where it expects to write log files. The
            server also writes the pid (process ID) file in the data
            directory.
     </p>
     <p>
      The default data directory location is hardcoded when the
            server is compiled. To determine what the default path
            settings are, invoke
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      with the
      <a class="link" href="server-options.html#option_mysqld_verbose">
       <code class="option">
        --verbose
       </code>
      </a>
      and
      <a class="link" href="server-options.html#option_mysqld_help">
       <code class="option">
        --help
       </code>
      </a>
      options. If the data
            directory is located somewhere else on your system, specify
            that location with the
      <a class="link" href="server-system-variables.html#sysvar_datadir">
       <code class="option">
        --datadir
       </code>
      </a>
      option to
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      or
      <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>
      ,
            on the command line or in an option file. Otherwise, the
            server does not work properly. As an alternative to the
      <a class="link" href="server-system-variables.html#sysvar_datadir">
       <code class="option">
        --datadir
       </code>
      </a>
      option, you can
            specify
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      the location of the base
            directory under which MySQL is installed with the
      <a class="link" href="server-system-variables.html#sysvar_basedir">
       <code class="option">
        --basedir
       </code>
      </a>
      , and
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      looks for the
      <code class="filename">
       data
      </code>
      directory there.
     </p>
     <p>
      To check the effect of specifying path options, invoke
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      with those options followed by the
      <a class="link" href="server-options.html#option_mysqld_verbose">
       <code class="option">
        --verbose
       </code>
      </a>
      and
      <a class="link" href="server-options.html#option_mysqld_help">
       <code class="option">
        --help
       </code>
      </a>
      options. For example,
            if you change location to the directory where
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      is installed and then run the
            following command, it shows the effect of starting the
            server with a base directory of
      <code class="filename">
       /usr/local
      </code>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa99228977"><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">./mysqld</span> <span class="token constant">--basedir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local</span> <span class="token property">--verbose</span> <span class="token property">--help</span></code></pre>
     </div>
     <p>
      You can specify other options such as
      <a class="link" href="server-system-variables.html#sysvar_datadir">
       <code class="option">
        --datadir
       </code>
      </a>
      as well, but
      <a class="link" href="server-options.html#option_mysqld_verbose">
       <code class="option">
        --verbose
       </code>
      </a>
      and
      <a class="link" href="server-options.html#option_mysqld_help">
       <code class="option">
        --help
       </code>
      </a>
      must be the last
            options.
     </p>
     <p>
      Once you determine the path settings you want, start the
            server without
      <a class="link" href="server-options.html#option_mysqld_verbose">
       <code class="option">
        --verbose
       </code>
      </a>
      and
      <a class="link" href="server-options.html#option_mysqld_help">
       <code class="option">
        --help
       </code>
      </a>
      .
     </p>
     <p>
      If
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      is currently running, you can
            find out what path settings it is using by executing this
            command:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa13371801"><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">mysqladmin</span> variables</code></pre>
     </div>
     <p>
      Or:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa87867263"><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">mysqladmin</span> <span class="token property">-h</span> <em class="replaceable">host_name</em> variables</code></pre>
     </div>
     <p>
      <em class="replaceable">
       <code>
        host_name
       </code>
      </em>
      is the name of the
            MySQL server host.
     </p>
    </li>
    <li class="listitem">
     <p>
      Make sure that the server can access the
      <a class="link" href="glossary.html#glos_data_directory" title="data directory">
       data directory
      </a>
      .
            The ownership and permissions of the data directory and its
            contents must allow the server to read and modify them.
     </p>
     <p>
      If you get
      <code class="literal">
       Errcode 13
      </code>
      (which means
      <code class="literal">
       Permission denied
      </code>
      ) when starting
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      , this means that the privileges of
            the data directory or its contents do not permit server
            access. In this case, you change the permissions for the
            involved files and directories so that the server has the
            right to use them. You can also start the server as
      <code class="literal">
       root
      </code>
      , but this raises security issues and
            should be avoided.
     </p>
     <p>
      Change location to the data directory and check the
            ownership of the data directory and its contents to make
            sure the server has access. For example, if the data
            directory is
      <code class="filename">
       /usr/local/mysql/var
      </code>
      , use
            this command:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa27052040"><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">ls</span> <span class="token property">-la</span> /usr/local/mysql/var</code></pre>
     </div>
     <p>
      If the data directory or its files or subdirectories are not
            owned by the login account that you use for running the
            server, change their ownership to that account. If the
            account is named
      <code class="literal">
       mysql
      </code>
      , use these
            commands:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa30736804"><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">chown</span> <span class="token property">-R</span> mysql /usr/local/mysql/var
<span class="token prompt">$&gt; </span><span class="token command">chgrp</span> <span class="token property">-R</span> mysql /usr/local/mysql/var</code></pre>
     </div>
     <p>
      Even with correct ownership, MySQL might fail to start up if
            there is other security software running on your system that
            manages application access to various parts of the file
            system. In this case, reconfigure that software to enable
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      to access the directories it uses
            during normal operation.
     </p>
    </li>
    <li class="listitem">
     <p>
      Verify that the network interfaces the server wants to use
            are available.
     </p>
     <p>
      If either of the following errors occur, it means that some
            other program (perhaps another
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server) is using the TCP/IP port or Unix socket file 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 use:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-none"><div class="docs-select-all right" id="sa36668448"><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">Can't start server: Bind on TCP/IP port: Address already in use
Can't start server: Bind on unix socket...</code></pre>
     </div>
     <p>
      Use
      <span class="command">
       <strong>
        ps
       </strong>
      </span>
      to determine whether you have
            another
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server running. If so,
            shut down the server before starting
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      again. (If another server is
            running, and you really want to run multiple servers, you
            can find information about how to do so in
      <a class="xref" href="multiple-servers.html" title="7.8 Running Multiple MySQL Instances on One Machine">
       Section 7.8, “Running Multiple MySQL Instances on One Machine”
      </a>
      .)
     </p>
     <p>
      If no other server is running, execute the command
      <code class="literal">
       telnet
       <em class="replaceable">
        <code>
         your_host_name
        </code>
       </em>
       <em class="replaceable">
        <code>
         tcp_ip_port_number
        </code>
       </em>
      </code>
      .
            (The default MySQL port number is 3306.) Then press Enter a
            couple of times. If you do not get an error message like
      <code class="literal">
       telnet: Unable to connect to remote host:
            Connection refused
      </code>
      , some other program is using
            the TCP/IP port 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
            use. Track down what program this is and disable it, or tell
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      to listen to a different port with
            the
      <a class="link" href="server-options.html#option_mysqld_port">
       <code class="option">
        --port
       </code>
      </a>
      option. In this
            case, specify the same non-default port number for client
            programs when connecting to the server using TCP/IP.
     </p>
     <p>
      Another reason the port might be inaccessible is that you
            have a firewall running that blocks connections to it. If
            so, modify the firewall settings to permit access to the
            port.
     </p>
     <p>
      If the server starts but you cannot connect to it, make sure
            that you have an entry in
      <code class="filename">
       /etc/hosts
      </code>
      that looks like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa62874326"><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">127.0.0.1       localhost</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      If you cannot get
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      to start, try to
            make a trace file to find the problem by using the
      <a class="link" href="server-options.html#option_mysqld_debug">
       <code class="option">
        --debug
       </code>
      </a>
      option. See
      <a class="xref" href="dbug-package.html" title="7.9.4 The DBUG Package">
       Section 7.9.4, “The DBUG Package”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
