<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="windows-troubleshooting">
      </a>
      2.3.4 Troubleshooting a Microsoft Windows MySQL Server Installation
     </h3>
    </div>
   </div>
  </div>
  <p>
   When installing and running MySQL for the first time, you may
      encounter certain errors that prevent the MySQL server from
      starting. This section helps you diagnose and correct some of
      these errors.
  </p>
  <p>
   Your first resource when troubleshooting server issues is the
   <a class="link" href="glossary.html#glos_error_log" title="error log">
    error log
   </a>
   . The MySQL server
      uses the error log to record information relevant to the error
      that prevents the server from starting. The error log is located
      in the
   <a class="link" href="glossary.html#glos_data_directory" title="data directory">
    data directory
   </a>
   specified in your
   <code class="filename">
    my.ini
   </code>
   file. The default
      data directory location is
   <code class="filename">
    C:\Program Files\MySQL\MySQL
      Server 8.4\data
   </code>
   , or
   <code class="filename">
    C:\ProgramData\Mysql
   </code>
   on Windows 7 and Windows
      Server 2008. The
   <code class="filename">
    C:\ProgramData
   </code>
   directory is
      hidden by default. You need to change your folder options to see
      the directory and contents. For more information on the error log
      and understanding the content, see
   <a class="xref" href="error-log.html" title="7.4.2 The Error Log">
    Section 7.4.2, “The Error Log”
   </a>
   .
  </p>
  <p>
   For information regarding possible errors, also consult the
      console messages displayed when the MySQL service is starting. Use
      the
   <span class="command">
    <strong>
     SC START
     <em class="replaceable">
      <code>
       mysqld_service_name
      </code>
     </em>
    </strong>
   </span>
   or
   <span class="command">
    <strong>
     NET START
     <em class="replaceable">
      <code>
       mysqld_service_name
      </code>
     </em>
    </strong>
   </span>
   command
      from the command line after installing
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   as a service to see any error messages regarding the starting of
      the MySQL server as a service. See
   <a class="xref" href="windows-start-service.html" title="2.3.3.8 Starting MySQL as a Windows Service">
    Section 2.3.3.8, “Starting MySQL as a Windows Service”
   </a>
   .
  </p>
  <p>
   The following examples show other common error messages you might
      encounter when installing MySQL and starting the server for the
      first time:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If the MySQL server cannot find the
      <code class="literal">
       mysql
      </code>
      privileges database or other critical files, it displays these
          messages:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-none"><div class="docs-select-all right" id="sa74720043"><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">System error 1067 has occurred.
Fatal error: Can't open and lock privilege tables:
Table 'mysql.user' doesn't exist</code></pre>
     </div>
     <p>
      These messages often occur when the MySQL base or data
          directories are installed in different locations than the
          default locations (
      <code class="filename">
       C:\Program Files\MySQL\MySQL
          Server 8.4
      </code>
      and
      <code class="filename">
       C:\Program
          Files\MySQL\MySQL Server 8.4\data
      </code>
      ,
          respectively).
     </p>
     <p>
      This situation can occur when MySQL is upgraded and installed
          to a new location, but the configuration file is not updated
          to reflect the new location. In addition, old and new
          configuration files might conflict. Be sure to delete or
          rename any old configuration files when upgrading MySQL.
     </p>
     <p>
      If you have installed MySQL to a directory other than
      <code class="filename">
       C:\Program Files\MySQL\MySQL Server
          8.4
      </code>
      , ensure that the MySQL server is
          aware of this through the use of a configuration
          (
      <code class="filename">
       my.ini
      </code>
      ) file. Put the
      <code class="filename">
       my.ini
      </code>
      file in your Windows directory,
          typically
      <code class="filename">
       C:\WINDOWS
      </code>
      . To determine its
          exact location from the value of the
      <code class="literal">
       WINDIR
      </code>
      environment variable, issue the following command from the
          command prompt:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa53703488"><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">C:\&gt;</span><span class="token command"> echo</span> %WINDIR%</code></pre>
     </div>
     <p>
      You can create or modify an option file with any text editor,
          such as Notepad. For example, if MySQL is installed in
      <code class="filename">
       E:\mysql
      </code>
      and the data directory is
      <code class="filename">
       D:\MySQLdata
      </code>
      , you can create the option
          file and set up a
      <code class="literal">
       [mysqld]
      </code>
      section to
          specify values for the
      <code class="option">
       basedir
      </code>
      and
      <code class="option">
       datadir
      </code>
      options:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa26338965"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token comment" spellcheck="true"># set basedir to your installation path</span>
<span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>E:/mysql</span>
<span class="token comment" spellcheck="true"># set datadir to the location of your data directory</span>
<span class="token constant">datadir</span><span class="token attr-value"><span class="token punctuation">=</span>D:/MySQLdata</span></code></pre>
     </div>
     <p>
      Microsoft Windows path names are specified in option files
          using (forward) slashes rather than backslashes. If you do use
          backslashes, double them:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa76423002"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token comment" spellcheck="true"># set basedir to your installation path</span>
<span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>C:\\Program Files\\MySQL\\MySQL Server 8.4</span>
<span class="token comment" spellcheck="true"># set datadir to the location of your data directory</span>
<span class="token constant">datadir</span><span class="token attr-value"><span class="token punctuation">=</span>D:\\MySQLdata</span></code></pre>
     </div>
     <p>
      The rules for use of backslash in option file values are given
          in
      <a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
       Section 6.2.2.2, “Using Option Files”
      </a>
      .
     </p>
     <p>
      If you change the
      <code class="option">
       datadir
      </code>
      value in your MySQL
          configuration file, you must move the contents of the existing
          MySQL data directory before restarting the MySQL server.
     </p>
     <p>
      See
      <a class="xref" href="windows-create-option-file.html" title="2.3.3.2 Creating an Option File">
       Section 2.3.3.2, “Creating an Option File”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you reinstall or upgrade MySQL without first stopping and
          removing the existing MySQL service, and then configure MySQL
          using MySQL Configurator, you might see this error:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa26823816"><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">Error: Cannot create Windows service for MySql. Error: 0</code></pre>
     </div>
     <p>
      This occurs when the Configuration Wizard tries to install the
          service and finds an existing service with the same name.
     </p>
     <p>
      One solution to this problem is to choose a service name other
          than
      <code class="literal">
       mysql
      </code>
      when using the configuration
          wizard. This enables the new service to be installed
          correctly, but leaves the outdated service in place. Although
          this is harmless, it is best to remove old services that are
          no longer in use.
     </p>
     <p>
      To permanently remove the old
      <code class="literal">
       mysql
      </code>
      service, execute the following command as a user with
          administrative privileges, on the command line:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa33388565"><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">C:\&gt;</span><span class="token command"> SC</span> DELETE mysql
<span class="token property"><span class="token punctuation">[</span>SC<span class="token punctuation">]</span></span> DeleteService SUCCESS</code></pre>
     </div>
     <p>
      If the
      <code class="literal">
       SC
      </code>
      utility is not available for your
          version of Windows, download the
      <code class="literal">
       delsrv
      </code>
      utility from
      <a class="ulink" href="http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/delsrv-o.asp" target="_blank">
       http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/delsrv-o.asp
      </a>
      and use the
      <code class="literal">
       delsrv mysql
      </code>
      syntax.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
