www.rodneybeede.com "I would love to change the world, but they won't give me the source code" - unknown

MySQL created user cannot connect via localhost - Last Modified 2009-04-02 03:32 UTC - Created 2009-04-02 03:32 UTC

I had an issue where I created a new MySQL user that would be allowed from any host. Whenever I tried to connect via localhost the user was always denied.

This is a common error due to the configuration of MySQL out of the box. The "anonymous" user matches first because it is defined as @% and @localhost. Since I was connecting as the new user that didn't have a specific @localhost entry the host part was being matched to the anonymous user first and denied.

The fix is to either add the @localhost to the newly created user specifically or delete the anonymous user.

Thanks goes to http://dev.mysql.com/doc/refman/5.0/en/connection-access.html which explained this quite well.