Are Users 'User'@'%' and 'User'@'localhost' not the same?

User@% would allow access from all locations. User@localhost would only allow access from localhost. They are two different users with two different passwords (though you can set them to the same password, but if you update one password the other will not auto-update)


Basically yes, those are two different users with (possibly) different permissions and (possibly) different passwords.

  • myuser@% : User myuser, connecting from any host.
  • myuser@localhost : User myuser, connecting from localhost only.

A good read is the MySQL manual about connection access, it demonstrates how it works.


I encountered the same situation as described - Adding an entry for user@% was not working.

Yet adding an entry for the same user@localhost would start to work again though. This did seem unintuitive, given our understanding of the % pattern!

An issue identified by Kent above was that: We had an entry row in the users table for host:localhost but the user was blank. This apparently resolved to a rule for %@localhost which was being used as a match before my user@% rule.

Short answer - check for blank or wildcard usernames in your user table.

... I have no idea how that blank got there or if it was intentional.