Home > Database > Mysql Tutorial > Why Does MySQL Return 'Access Denied' Even with the Correct Password?

Why Does MySQL Return 'Access Denied' Even with the Correct Password?

DDD
Release: 2024-12-20 12:21:11
Original
858 people have browsed it

Why Does MySQL Return

MySQL Error 1045: Access Denied for User with Correct Password

When attempting to connect to a MySQL instance as a newly created user 'bill', the error "ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)" is encountered. Despite providing the correct password, access is denied.

Understanding the Issue

As per the documentation, MySQL prioritizes user accounts with the most specific Host values first. In this case, there is likely an anonymous user account ''@'localhost' or ''@'127.0.0.1', which would match 'bill'@'%' and take precedence, effectively blocking the intended connection.

Recommended Solution

To resolve the issue, it is recommended to drop the anonymous user. This user often exists in default installations and should be removed for security reasons.

Related Observations

Additional insights from the provided setup:

  1. It is possible to authenticate as 'bill'@'%' through a socket, provided there are no matching anonymous users.
  2. The authentication mechanism is unaffected by connecting via TCP or socket.
  3. Specifying a specific user for authentication through the command line may still result in access granted to an anonymous user due to the "sorting rules" mentioned in the MySQL documentation. This underscores the importance of disabling or removing anonymous users.

The above is the detailed content of Why Does MySQL Return 'Access Denied' Even with the Correct Password?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template