Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8143447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:07:35+00:00 2026-06-06T13:07:35+00:00

First let me mention that I’ve gone through many suggested questions and found no

  • 0

First let me mention that I’ve gone through many suggested questions and found no relevent answer. Here is what I’m doing.

I’m connected to my Amazon EC2 instance. I can login with MySQL root with this command:

mysql -u root -p

Then I created a new user bill with host %

CREATE USER 'bill'@'%' IDENTIFIED BY 'passpass';

Granted all the privileges to user bill:

grant all privileges on *.* to 'bill'@'%' with grant option;

Then I exit from root user and try to login with bill:

mysql -u bill -p

entered the correct password and got this error:

ERROR 1045 (28000): Access denied for user ‘bill’@’localhost’ (using password: YES)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:07:36+00:00Added an answer on June 6, 2026 at 1:07 pm

    You probably have an anonymous user ''@'localhost' or ''@'127.0.0.1'.

    As per the manual:

    When multiple matches are possible, the server must determine which of
    them to use. It resolves this issue as follows: (…)

    • When a client attempts to connect, the server looks through the rows [of table mysql.user] in sorted order.
    • The server uses the first row that matches the client host name and user name.

    (…)
    The server uses sorting rules that order rows with the most-specific Host values first.
    Literal host names [such as ‘localhost’] and IP addresses are the most specific.

    Therefore such an anonymous user would "mask" any other user like '[any_username]'@'%' when connecting from localhost.

    'bill'@'localhost' does match 'bill'@'%', but would match (e.g.) ''@'localhost' beforehands.

    The recommended solution is to drop this anonymous user (this is usually a good thing to do anyways).


    Below edits are mostly irrelevant to the main question. These are only meant to answer some questions raised in other comments within this thread.

    Edit 1

    Authenticating as 'bill'@'%' through a socket.

    
        root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass --socket=/tmp/mysql-5.5.sock
        Welcome to the MySQL monitor (...)
        
        mysql> SELECT user, host FROM mysql.user;
        +------+-----------+
        | user | host      |
        +------+-----------+
        | bill | %         |
        | root | 127.0.0.1 |
        | root | ::1       |
        | root | localhost |
        +------+-----------+
        4 rows in set (0.00 sec)
        
        mysql> SELECT USER(), CURRENT_USER();
        +----------------+----------------+
        | USER()         | CURRENT_USER() |
        +----------------+----------------+
        | bill@localhost | bill@%         |
        +----------------+----------------+
        1 row in set (0.02 sec)
        
        mysql> SHOW VARIABLES LIKE 'skip_networking';
        +-----------------+-------+
        | Variable_name   | Value |
        +-----------------+-------+
        | skip_networking | ON    |
        +-----------------+-------+
        1 row in set (0.00 sec)
        
    

    Edit 2

    Exact same setup, except I re-activated networking, and I now create an anonymous user ''@'localhost'.

    
        root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql
        Welcome to the MySQL monitor (...)
        
        mysql> CREATE USER ''@'localhost' IDENTIFIED BY 'anotherpass';
        Query OK, 0 rows affected (0.00 sec)
        
        mysql> Bye
    
        root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass \
            --socket=/tmp/mysql-5.5.sock
        ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
        root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass \
            -h127.0.0.1 --protocol=TCP
        ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
        root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass \
            -hlocalhost --protocol=TCP
        ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
    
    

    Edit 3

    Same situation as in edit 2, now providing the anonymous user’s password.

    
        root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -panotherpass -hlocalhost
        Welcome to the MySQL monitor (...)
    
        mysql> SELECT USER(), CURRENT_USER();
        +----------------+----------------+
        | USER()         | CURRENT_USER() |
        +----------------+----------------+
        | bill@localhost | @localhost     |
        +----------------+----------------+
        1 row in set (0.01 sec)
    
    

    Conclusion 1, from edit 1: One can authenticate as 'bill'@'%'through a socket.

    Conclusion 2, from edit 2: Whether one connects through TCP or through a socket has no impact on the authentication process (except one cannot connect as anyone else but 'something'@'localhost' through a socket, obviously).

    Conclusion 3, from edit 3: Although I specified -ubill, I have been granted access as an anonymous user. This is because of the "sorting rules" advised above. Notice that in most default installations, a no-password, anonymous user exists (and should be secured/removed).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, let me just mention that this is my first attempt at a from-the-ground-up
First let me state that, despite being a fairly new practitioner of TDD, I'm
First let me say that I did see this article: How to remove AspxAutoDetectCookieSupport
First let me explain. I have several addresses on the page that I put
I can't figure this one out. At first let me say that my cache
First let me explain that I've created a million lib directories scouring out all
First let me say that I know it's better to use the subprocess module,
First let me note, that I use AspectJ and I like it, but what
First let me say that I can remote debug a release build on the
Let me first say that I've got a fair amount of experience in both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.