<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="problems-connecting">
      </a>
      8.2.22 Troubleshooting Problems Connecting to MySQL
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045247487616">
  </a>
  <a class="indexterm" name="idm46045247486576">
  </a>
  <a class="indexterm" name="idm46045247485088">
  </a>
  <p>
   If you encounter problems when you try to connect to the MySQL
      server, the following items describe some courses of action you
      can take to correct the problem.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Make sure that the server is running. If it is not, clients
          cannot connect to it. For example, if an attempt to connect to
          the server fails with a message such as one of those
          following, one cause might be that the server is not running:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa13028401"><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">mysql</span>
<span class="token output">ERROR 2003<span class="token punctuation">:</span> Can't connect to MySQL server on '<em class="replaceable">host_name</em>' (111)</span>
<span class="token prompt">$&gt; </span><span class="token command">mysql</span>
<span class="token output">ERROR 2002<span class="token punctuation">:</span> Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (111)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      It might be that the server is running, but you are trying to
          connect using a TCP/IP port, named pipe, or Unix socket file
          different from the one on which the server is listening. To
          correct this when you invoke a client program, specify a
      <a class="link" href="connection-options.html#option_general_port">
       <code class="option">
        --port
       </code>
      </a>
      option to indicate the
          proper port number, or a
      <a class="link" href="connection-options.html#option_general_socket">
       <code class="option">
        --socket
       </code>
      </a>
      option to indicate
          the proper named pipe or Unix socket file. To find out where
          the socket file is, you can use this command:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa1513924"><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">netstat</span> <span class="token property">-ln</span> | grep mysql</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Make sure that the server has not been configured to ignore
          network connections or (if you are attempting to connect
          remotely) that it has not been configured to listen only
          locally on its network interfaces. If the server was started
          with the
      <a class="link" href="server-system-variables.html#sysvar_skip_networking">
       <code class="literal">
        skip_networking
       </code>
      </a>
      system variable enabled, no TCP/IP connections are accepted.
          If the server was started with the
      <a class="link" href="server-system-variables.html#sysvar_bind_address">
       <code class="literal">
        bind_address
       </code>
      </a>
      system variable
          set to
      <code class="literal">
       127.0.0.1
      </code>
      , it listens for TCP/IP
          connections only locally on the loopback interface and does
          not accept remote connections.
     </p>
    </li>
    <li class="listitem">
     <p>
      Check to make sure that there is no firewall blocking access
          to MySQL. Your firewall may be configured on the basis of the
          application being executed, or the port number used by MySQL
          for communication (3306 by default). Under Linux or Unix,
          check your IP tables (or similar) configuration to ensure that
          the port has not been blocked. Under Windows, applications
          such as ZoneAlarm or Windows Firewall may need to be
          configured not to block the MySQL port.
     </p>
    </li>
    <li class="listitem">
     <p>
      The grant tables must be properly set up so that the server
          can use them for access control. For some distribution types
          (such as binary distributions on Windows, or RPM and DEB
          distributions on Linux), the installation process initializes
          the MySQL data directory, including the
      <code class="literal">
       mysql
      </code>
      system database containing the grant
          tables. For distributions that do not do this, you must
          initialize the data directory manually. For details, see
      <a class="xref" href="postinstallation.html" title="2.9 Postinstallation Setup and Testing">
       Section 2.9, “Postinstallation Setup and Testing”
      </a>
      .
     </p>
     <p>
      To determine whether you need to initialize the grant tables,
          look for a
      <code class="filename">
       mysql
      </code>
      directory under the data
          directory. (The data directory normally is named
      <code class="filename">
       data
      </code>
      or
      <code class="filename">
       var
      </code>
      and is
          located under your MySQL installation directory.) Make sure
          that you have a file named
      <code class="filename">
       user.MYD
      </code>
      in
          the
      <code class="filename">
       mysql
      </code>
      database directory. If not,
          initialize the data directory. After doing so and starting the
          server, you should be able to connect to the server.
     </p>
    </li>
    <li class="listitem">
     <p>
      After a fresh installation, if you try to log on to the server
          as
      <code class="literal">
       root
      </code>
      without using a password, you might
          get the following error message.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa44919376"><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">mysql</span> <span class="token property">-u</span> root 
<span class="token output">ERROR 1045 (28000)<span class="token punctuation">:</span> Access denied for user 'root'@'localhost' (using password<span class="token punctuation">:</span> NO)</span></code></pre>
     </div>
     <p>
      It means a root password has already been assigned during
          installation and it has to be supplied. See
      <a class="xref" href="default-privileges.html" title="2.9.4 Securing the Initial MySQL Account">
       Section 2.9.4, “Securing the Initial MySQL Account”
      </a>
      on the different ways the
          password could have been assigned and, in some cases, how to
          find it. If you need to reset the root password, see
          instructions in
      <a class="xref" href="resetting-permissions.html" title="B.3.3.2 How to Reset the Root Password">
       Section B.3.3.2, “How to Reset the Root Password”
      </a>
      . After
          you have found or reset your password, log on again as
      <code class="literal">
       root
      </code>
      using the
      <a class="link" href="connection-options.html#option_general_password">
       <code class="option">
        --password
       </code>
      </a>
      (or
      <a class="link" href="connection-options.html#option_general_password">
       <code class="option">
        -p
       </code>
      </a>
      )
          option:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa24538915"><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">mysql</span> <span class="token property">-u</span> root <span class="token property">-p</span>
Enter password<span class="token punctuation">:</span></code></pre>
     </div>
     <p>
      However, the server is going to let you connect as
      <code class="literal">
       root
      </code>
      without using a password if you have
          initialized MySQL using
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
          --initialize-insecure
        </strong>
       </span>
      </a>
      (see
      <a class="xref" href="data-directory-initialization.html" title="2.9.1 Initializing the Data Directory">
       Section 2.9.1, “Initializing the Data Directory”
      </a>
      for details).
          That is a security risk, so you should set a password for the
      <code class="literal">
       root
      </code>
      account; see
      <a class="xref" href="default-privileges.html" title="2.9.4 Securing the Initial MySQL Account">
       Section 2.9.4, “Securing the Initial MySQL Account”
      </a>
      for instructions.
     </p>
    </li>
    <li class="listitem">
     <p>
      If you have updated an existing MySQL installation to a newer
          version, did you perform the MySQL upgrade procedure? If not,
          do so. The structure of the grant tables changes occasionally
          when new capabilities are added, so after an upgrade you
          should always make sure that your tables have the current
          structure. For instructions, see
      <a class="xref" href="upgrading.html" title="Chapter 3 Upgrading MySQL">
       Chapter 3,
       <i>
        Upgrading MySQL
       </i>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If a client program receives the following error message when
          it tries to connect, it means that the server expects
          passwords in a newer format than the client is capable of
          generating:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa36526359"><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">mysql</span>
Client does not support authentication protocol requested
by server<span class="token punctuation">;</span> consider upgrading MySQL client</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045247441696">
      </a>
      <a class="indexterm" name="idm46045247440624">
      </a>
      <a class="indexterm" name="idm46045247439552">
      </a>
      <a class="indexterm" name="idm46045247438480">
      </a>
      <a class="indexterm" name="idm46045247437408">
      </a>
      Remember that client programs use connection parameters
          specified in option files or environment variables. If a
          client program seems to be sending incorrect default
          connection parameters when you have not specified them on the
          command line, check any applicable option files and your
          environment. For example, if you get
      <code class="literal">
       Access
          denied
      </code>
      when you run a client without any options,
          make sure that you have not specified an old password in any
          of your option files!
     </p>
     <p>
      You can suppress the use of option files by a client program
          by invoking it with the
      <a class="link" href="option-file-options.html#option_general_no-defaults">
       <code class="option">
        --no-defaults
       </code>
      </a>
      option. For
          example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa25630822"><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">--no-defaults</span> <span class="token property">-u</span> root version</code></pre>
     </div>
     <p>
      The option files that clients use are listed 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>
      . Environment variables are
          listed in
      <a class="xref" href="environment-variables.html" title="6.9 Environment Variables">
       Section 6.9, “Environment Variables”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you get the following error, it means that you are using an
          incorrect
      <code class="literal">
       root
      </code>
      password:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa22646501"><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">-u</span> root <span class="token property">-p<em class="replaceable">xxxx</em></span> ver
Access denied for user <span class="token atrule">'root'</span>@<span class="token atrule">'localhost'</span> <span class="token punctuation">(</span>using password<span class="token punctuation">:</span> YES<span class="token punctuation">)</span></code></pre>
     </div>
     <p>
      If the preceding error occurs even when you have not specified
          a password, it means that you have an incorrect password
          listed in some option file. Try the
      <a class="link" href="option-file-options.html#option_general_no-defaults">
       <code class="option">
        --no-defaults
       </code>
      </a>
      option as
          described in the previous item.
     </p>
     <p>
      For information on changing passwords, see
      <a class="xref" href="assigning-passwords.html" title="8.2.14 Assigning Account Passwords">
       Section 8.2.14, “Assigning Account Passwords”
      </a>
      .
     </p>
     <p>
      If you have lost or forgotten the
      <code class="literal">
       root
      </code>
      password, see
      <a class="xref" href="resetting-permissions.html" title="B.3.3.2 How to Reset the Root Password">
       Section B.3.3.2, “How to Reset the Root Password”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       localhost
      </code>
      is a synonym for your local host
          name, and is also the default host to which clients try to
          connect if you specify no host explicitly.
     </p>
     <p>
      You can use a
      <a class="link" href="connection-options.html#option_general_host">
       <code class="option">
        --host=127.0.0.1
       </code>
      </a>
      option to name the server host explicitly. This causes a
          TCP/IP connection to the local
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server. You can also use TCP/IP by specifying a
      <a class="link" href="connection-options.html#option_general_host">
       <code class="option">
        --host
       </code>
      </a>
      option that uses the
          actual host name of the local host. In this case, the host
          name must be specified in a
      <code class="literal">
       user
      </code>
      table row
          on the server host, even though you are running the client
          program on the same host as the server.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       Access denied
      </code>
      error message tells you
          who you are trying to log in as, the client host from which
          you are trying to connect, and whether you were using a
          password. Normally, you should have one row in the
      <code class="literal">
       user
      </code>
      table that exactly matches the host
          name and user name that were given in the error message. For
          example, if you get an error message that contains
      <code class="literal">
       using password: NO
      </code>
      , it means that you tried
          to log in without a password.
     </p>
    </li>
    <li class="listitem">
     <p>
      If you get an
      <code class="literal">
       Access denied
      </code>
      error when
          trying to connect to the database with
      <code class="literal">
       mysql -u
       <em class="replaceable">
        <code>
         user_name
        </code>
       </em>
      </code>
      , you may have a
          problem with the
      <code class="literal">
       user
      </code>
      table. Check this by
          executing
      <code class="literal">
       mysql -u root mysql
      </code>
      and issuing
          this SQL statement:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa33604076"><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">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token keyword">user</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      The result should include a row with the
      <code class="literal">
       Host
      </code>
      and
      <code class="literal">
       User
      </code>
      columns
          matching your client's host name and your MySQL user name.
     </p>
    </li>
    <li class="listitem">
     <p>
      If the following error occurs when you try to connect from a
          host other than the one on which the MySQL server is running,
          it means that there is no row in the
      <code class="literal">
       user
      </code>
      table with a
      <code class="literal">
       Host
      </code>
      value that matches the
          client host:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa36499146"><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">Host ... is not allowed to connect to this MySQL server</code></pre>
     </div>
     <p>
      You can fix this by setting up an account for the combination
          of client host name and user name that you are using when
          trying to connect.
     </p>
     <p>
      If you do not know the IP address or host name of the machine
          from which you are connecting, you should put a row with
      <code class="literal">
       '%'
      </code>
      as the
      <code class="literal">
       Host
      </code>
      column
          value in the
      <code class="literal">
       user
      </code>
      table. After trying to
          connect from the client machine, use a
      <code class="literal">
       SELECT
          USER()
      </code>
      query to see how you really did connect. Then
          change the
      <code class="literal">
       '%'
      </code>
      in the
      <code class="literal">
       user
      </code>
      table row to the actual host name that
          shows up in the log. Otherwise, your system is left insecure
          because it permits connections from any host for the given
          user name.
     </p>
     <p>
      On Linux, another reason that this error might occur is that
          you are using a binary MySQL version that is compiled with a
          different version of the
      <code class="literal">
       glibc
      </code>
      library than
          the one you are using. In this case, you should either upgrade
          your operating system or
      <code class="literal">
       glibc
      </code>
      , or download
          a source distribution of MySQL version and compile it
          yourself. A source RPM is normally trivial to compile and
          install, so this is not a big problem.
     </p>
    </li>
    <li class="listitem">
     <p>
      If you specify a host name when trying to connect, but get an
          error message where the host name is not shown or is an IP
          address, it means that the MySQL server got an error when
          trying to resolve the IP address of the client host to a name:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa75392197"><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">-u</span> root <span class="token property">-p<em class="replaceable">xxxx</em></span> <span class="token property">-h</span> <em class="replaceable">some_hostname</em> ver
Access denied for user <span class="token atrule">'root'</span>@<span class="token atrule">''</span> <span class="token punctuation">(</span>using password<span class="token punctuation">:</span> YES<span class="token punctuation">)</span></code></pre>
     </div>
     <p>
      If you try to connect as
      <code class="literal">
       root
      </code>
      and get the
          following error, it means that you do not have a row in the
      <code class="literal">
       user
      </code>
      table with a
      <code class="literal">
       User
      </code>
      column value of
      <code class="literal">
       'root'
      </code>
      and that
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      cannot resolve the host name for
          your client:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa96434277"><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">Access denied for user ''@'unknown'</code></pre>
     </div>
     <p>
      These errors indicate a DNS problem. To fix it, execute
      <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
       <span class="command">
        <strong>
         mysqladmin flush-hosts
        </strong>
       </span>
      </a>
      to reset the
          internal DNS host cache. See
      <a class="xref" href="host-cache.html" title="7.1.12.3 DNS Lookups and the Host Cache">
       Section 7.1.12.3, “DNS Lookups and the Host Cache”
      </a>
      .
     </p>
     <p>
      Some permanent solutions are:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         Determine what is wrong with your DNS server and fix it.
        </p>
       </li>
       <li class="listitem">
        <p>
         Specify IP addresses rather than host names in the MySQL
              grant tables.
        </p>
       </li>
       <li class="listitem">
        <p>
         Put an entry for the client machine name in
         <code class="filename">
          /etc/hosts
         </code>
         on Unix or
         <code class="filename">
          \windows\hosts
         </code>
         on Windows.
        </p>
       </li>
       <li class="listitem">
        <p>
         Start
         <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-system-variables.html#sysvar_skip_name_resolve">
          <code class="literal">
           skip_name_resolve
          </code>
         </a>
         system
              variable enabled.
        </p>
       </li>
       <li class="listitem">
        <p>
         Start
         <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
          <span class="command">
           <strong>
            mysqld
           </strong>
          </span>
         </a>
         with
         <a class="link" href="server-system-variables.html#sysvar_host_cache_size">
          <code class="option">
           --host-cache-size=0
          </code>
         </a>
         .
        </p>
       </li>
       <li class="listitem">
        <p>
         On Unix, if you are running the server and the client on
              the same machine, connect to
         <code class="literal">
          localhost
         </code>
         .
              For connections to
         <code class="literal">
          localhost
         </code>
         , MySQL
              programs attempt to connect to the local server by using a
              Unix socket file, unless there are connection parameters
              specified to ensure that the client makes a TCP/IP
              connection. For more information, see
         <a class="xref" href="connecting.html" title="6.2.4 Connecting to the MySQL Server Using Command Options">
          Section 6.2.4, “Connecting to the MySQL Server Using Command Options”
         </a>
         .
        </p>
       </li>
       <li class="listitem">
        <p>
         On Windows, if you are running the server and the client
              on the same machine and the server supports named pipe
              connections, connect to the host name
         <code class="literal">
          .
         </code>
         (period). Connections to
         <code class="literal">
          .
         </code>
         use a named
              pipe rather than TCP/IP.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      If
      <code class="literal">
       mysql -u root
      </code>
      works but
      <code class="literal">
       mysql
          -h
       <em class="replaceable">
        <code>
         your_hostname
        </code>
       </em>
       -u root
      </code>
      results in
      <code class="literal">
       Access denied
      </code>
      (where
      <em class="replaceable">
       <code>
        your_hostname
       </code>
      </em>
      is the actual host
          name of the local host), you may not have the correct name for
          your host in the
      <code class="literal">
       user
      </code>
      table. A common
          problem here is that the
      <code class="literal">
       Host
      </code>
      value in the
      <code class="literal">
       user
      </code>
      table row specifies an unqualified
          host name, but your system's name resolution routines return a
          fully qualified domain name (or vice versa). For example, if
          you have a row with host
      <code class="literal">
       'pluto'
      </code>
      in the
      <code class="literal">
       user
      </code>
      table, but your DNS tells MySQL that
          your host name is
      <code class="literal">
       'pluto.example.com'
      </code>
      , the
          row does not work. Try adding a row to the
      <code class="literal">
       user
      </code>
      table that contains the IP address of
          your host as the
      <code class="literal">
       Host
      </code>
      column value.
          (Alternatively, you could add a row to the
      <code class="literal">
       user
      </code>
      table with a
      <code class="literal">
       Host
      </code>
      value that contains a wildcard (for example,
      <code class="literal">
       'pluto.%'
      </code>
      ). However, use of
      <code class="literal">
       Host
      </code>
      values ending with
      <code class="literal">
       %
      </code>
      is
      <span class="emphasis">
       <em>
        insecure
       </em>
      </span>
      and is
      <span class="emphasis">
       <em>
        not
       </em>
      </span>
      recommended!)
     </p>
    </li>
    <li class="listitem">
     <p>
      If
      <code class="literal">
       mysql -u
       <em class="replaceable">
        <code>
         user_name
        </code>
       </em>
      </code>
      works but
      <code class="literal">
       mysql -u
       <em class="replaceable">
        <code>
         user_name
        </code>
       </em>
       <em class="replaceable">
        <code>
         some_db
        </code>
       </em>
      </code>
      does not, you
          have not granted access to the given user for the database
          named
      <em class="replaceable">
       <code>
        some_db
       </code>
      </em>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If
      <code class="literal">
       mysql -u
       <em class="replaceable">
        <code>
         user_name
        </code>
       </em>
      </code>
      works when
          executed on the server host, but
      <code class="literal">
       mysql -h
       <em class="replaceable">
        <code>
         host_name
        </code>
       </em>
       -u
       <em class="replaceable">
        <code>
         user_name
        </code>
       </em>
      </code>
      does not work
          when executed on a remote client host, you have not enabled
          access to the server for the given user name from the remote
          host.
     </p>
    </li>
    <li class="listitem">
     <p>
      If you cannot figure out why you get
      <code class="literal">
       Access
          denied
      </code>
      , remove from the
      <code class="literal">
       user
      </code>
      table all rows that have
      <code class="literal">
       Host
      </code>
      values
          containing wildcards (rows that contain
      <code class="literal">
       '%'
      </code>
      or
      <code class="literal">
       '_'
      </code>
      characters). A very common error is
          to insert a new row with
      <code class="literal">
       Host
      </code>
      =
      <code class="literal">
       '%'
      </code>
      and
      <code class="literal">
       User
      </code>
      =
      <code class="literal">
       '
       <em class="replaceable">
        <code>
         some_user
        </code>
       </em>
       '
      </code>
      ,
          thinking that this enables you to specify
      <code class="literal">
       localhost
      </code>
      to connect from the same machine.
          The reason that this does not work is that the default
          privileges include a row with
      <code class="literal">
       Host
      </code>
      =
      <code class="literal">
       'localhost'
      </code>
      and
      <code class="literal">
       User
      </code>
      =
      <code class="literal">
       ''
      </code>
      . Because that
          row has a
      <code class="literal">
       Host
      </code>
      value
      <code class="literal">
       'localhost'
      </code>
      that is more specific than
      <code class="literal">
       '%'
      </code>
      , it is used in preference to the new
          row when connecting from
      <code class="literal">
       localhost
      </code>
      ! The
          correct procedure is to insert a second row with
      <code class="literal">
       Host
      </code>
      =
      <code class="literal">
       'localhost'
      </code>
      and
      <code class="literal">
       User
      </code>
      =
      <code class="literal">
       '
       <em class="replaceable">
        <code>
         some_user
        </code>
       </em>
       '
      </code>
      ,
          or to delete the row with
      <code class="literal">
       Host
      </code>
      =
      <code class="literal">
       'localhost'
      </code>
      and
      <code class="literal">
       User
      </code>
      =
      <code class="literal">
       ''
      </code>
      . After deleting
          the row, remember to issue a
      <a class="link" href="flush.html#flush-privileges">
       <code class="literal">
        FLUSH
          PRIVILEGES
       </code>
      </a>
      statement to reload the grant tables. See
          also
      <a class="xref" href="connection-access.html" title="8.2.6 Access Control, Stage 1: Connection Verification">
       Section 8.2.6, “Access Control, Stage 1: Connection Verification”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you are able to connect to the MySQL server, but get an
      <code class="literal">
       Access denied
      </code>
      message whenever you issue a
      <a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
       <code class="literal">
        SELECT ... INTO
          OUTFILE
       </code>
      </a>
      or
      <a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
       <code class="literal">
        LOAD DATA
       </code>
      </a>
      statement, your row in the
      <code class="literal">
       user
      </code>
      table does
          not have the
      <a class="link" href="privileges-provided.html#priv_file">
       <code class="literal">
        FILE
       </code>
      </a>
      privilege
          enabled.
     </p>
    </li>
    <li class="listitem">
     <p>
      If you change the grant tables directly (for example, by using
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      ,
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      , or
      <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
       <code class="literal">
        DELETE
       </code>
      </a>
      statements) and your
          changes seem to be ignored, remember that you must execute a
      <a class="link" href="flush.html#flush-privileges">
       <code class="literal">
        FLUSH PRIVILEGES
       </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-privileges
        </strong>
       </span>
      </a>
      command to
          cause the server to reload the privilege tables. Otherwise,
          your changes have no effect until the next time the server is
          restarted. Remember that after you change the
      <code class="literal">
       root
      </code>
      password with an
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      statement, you do not
          need to specify the new password until after you flush the
          privileges, because the server does not know until then that
          you have changed the password.
     </p>
    </li>
    <li class="listitem">
     <p>
      If your privileges seem to have changed in the middle of a
          session, it may be that a MySQL administrator has changed
          them. Reloading the grant tables affects new client
          connections, but it also affects existing connections as
          indicated in
      <a class="xref" href="privilege-changes.html" title="8.2.13 When Privilege Changes Take Effect">
       Section 8.2.13, “When Privilege Changes Take Effect”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you have access problems with a Perl, PHP, Python, or ODBC
          program, try to connect to the server with
      <code class="literal">
       mysql -u
       <em class="replaceable">
        <code>
         user_name
        </code>
       </em>
       <em class="replaceable">
        <code>
         db_name
        </code>
       </em>
      </code>
      or
      <code class="literal">
       mysql
          -u
       <em class="replaceable">
        <code>
         user_name
        </code>
       </em>
       -p
       <em class="replaceable">
        <code>
         password
        </code>
       </em>
       <em class="replaceable">
        <code>
         db_name
        </code>
       </em>
      </code>
      . If you are able
          to connect using the
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      client, the
          problem lies with your program, not with the access
          privileges. (There is no space between
      <code class="option">
       -p
      </code>
      and
          the password; you can also use the
      <a class="link" href="connection-options.html#option_general_password">
       <code class="option">
        --password=
        <em class="replaceable">
         <code>
          password
         </code>
        </em>
       </code>
      </a>
      syntax to specify the password. If you use the
      <code class="option">
       -p
      </code>
      or
      <a class="link" href="connection-options.html#option_general_password">
       <code class="option">
        --password
       </code>
      </a>
      option with no
          password value, MySQL prompts you for the password.)
     </p>
    </li>
    <li class="listitem">
     <p>
      For testing purposes, start the
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server with the
      <a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
       <code class="option">
        --skip-grant-tables
       </code>
      </a>
      option.
          Then you can change the MySQL grant tables and use the
      <a class="link" href="show-grants.html" title="15.7.7.22 SHOW GRANTS Statement">
       <code class="literal">
        SHOW GRANTS
       </code>
      </a>
      statement to check
          whether your modifications have the desired effect. When you
          are satisfied with your changes, execute
      <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
       <span class="command">
        <strong>
         mysqladmin
          flush-privileges
        </strong>
       </span>
      </a>
      to tell the
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server to reload the privileges.
          This enables you to begin using the new grant table contents
          without stopping and restarting the server.
     </p>
    </li>
    <li class="listitem">
     <p>
      If everything else fails, start the
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server with a debugging option (for example,
      <a class="link" href="server-options.html#option_mysqld_debug">
       <code class="option">
        --debug=d,general,query
       </code>
      </a>
      ). This
          prints host and user information about attempted connections,
          as well as information about each command issued. 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>
    <li class="listitem">
     <p>
      If you have any other problems with the MySQL grant tables and
          ask on the
      <a class="ulink" href="https://mysqlcommunity.slack.com/" target="_blank">
       MySQL Community
          Slack
      </a>
      , always provide a dump of the MySQL grant
          tables. You can dump the tables with the
      <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
       <span class="command">
        <strong>
         mysqldump
          mysql
        </strong>
       </span>
      </a>
      command. To file a bug report, see the
          instructions at
      <a class="xref" href="bug-reports.html" title="1.6 How to Report Bugs or Problems">
       Section 1.6, “How to Report Bugs or Problems”
      </a>
      . In some cases,
          you may need to restart
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      with
      <a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
       <code class="option">
        --skip-grant-tables
       </code>
      </a>
      to run
      <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
       <span class="command">
        <strong>
         mysqldump
        </strong>
       </span>
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
