Mathieu Bruneau wrote:
> Baron Schwartz a écrit :
>> Miguel Cardenas wrote:
>>> Hello list
>>> I have a problem adding a user with host '%' ...
>>> *** If I add a user with host '%' when trying to connect get this error:
>>> ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using
>>> password: YES)
>>> *** If I add the same user with localhost it connects and works fine...
>>> My specific doubt is:
>>> 1) do I need to add a same user with both '%' and 'localhost' to
>>> connect locally and from another location???, or...
>>> 2) for some reason a host '%' is not working or need to do something
>>> so it allows connections from any host?
>> Remember to quote the user and host carefully. So,
>> GRANT ... TO 'user'@'%'
>> GRANT ... TO user@%
>> If you have doubts about what you actually granted, do this:
>> SHOW GRANTS FOR 'user'
>> And see what host it claims the permissions are for. If you did it
>> wrong, it will say no such user exists. If you do all this and
>> everything looks okay, write back to the list again and maybe we can
>> help you more.
>> Oh, one more place to look is at the server configuration in /etc/my.cnf
>> or equivalent, to be sure networking is configured right. You want to
>> check the bind-address and skip-networking settings. You don't want
>> skip-networking, and you want bind-address set to the machine's IP
>> address. Now that I think of it, this is more likely to be the problem
>> for you.
> Localhost is indeed a special value that isn't include in '%'. It's a
> feature not a bug ;)
Hm, I didn't know that! I thought it was only a special value to the client
tools, which I know will try to connect via socket on UNIX machines when they
see 'localhost' but will try to connect via TCP/IP when they see '127.0.0.1'.
Thanks for pointing this out!