MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 22 2004 12:21am
Subject:Re: Any way to make anyhost '%' include localhost
View as plain text  
At 18:04 -0600 2/21/04, Jason Joines wrote:
>Paul DuBois wrote:
>>At 8:21 -0600 2/21/04, Jason Joines wrote:
>>
>>>     We have a web server where users connect to mysql in scripts, 
>>>etc., via the host name localhost.  We would also like for them to 
>>>be able to manage their databases from their office dekstops with 
>>>various utilities.  If we grant rights to username@localhost, they 
>>>can connect from the web/mysql server itself but not from other 
>>>locations as expected.  However, if we grant rights to 
>>>username@'%', they can connect from any host other than the web 
>>>server.  To allow connections from any host (including the 
>>>web/mysql server, localhost) we have to try and keep two sets of 
>>>permissions synchonized for each user, username@localhost and 
>>>username@%, effectively doubling the number of users we have to 
>>>manage.
>>>     Is there any way to allow connections from both the localhost 
>>>and any other host with one set of permissions per user?
>>>
>>
>>Check the user table to see if there is an account with a Host value of
>>'localhost' and a User value of '' (empty string).  If there is, remove
>>it (DELETE FROM user WHERE Host='localhost' AND User='') and then do
>>FLUSH PRIVILEGES.
>>
>>The reason this happens is explained here:
>>
>>http://www.mysql.com/doc/en/Connection_access.html
>>
>>See the discussion about user table sorting.
>
>
>	Thanks, I certainly had that "common misconception". 
>Removing the mysql.user table record for ''@localhost made the 
>permissions behave the way we wanted.  I sure don't remember adding 
>that though.

You probably didn't add it.  It's one of the default accounts that is
created during the MySQL installation procedure.

I find that the anonymous-user accounts aren't very helpful, so I always
remove them.  Then this confusing phenomenon doesn't occur.

>
>	Something I didn't see in the document was a blank host value 
>in the users table.  What's the difference between username@'%' and 
>username@''?

In the user (not users) table, they're the same.  '%' is probably preferable,
because it's more easily recognized as a pattern.


-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

MySQL Users Conference: April 14-16, 2004
http://www.mysql.com/uc2004/
Thread
Any way to make anyhost '%' include localhostJason Joines21 Feb
  • Re: Any way to make anyhost '%' include localhostEgor Egorov21 Feb
  • Re: Any way to make anyhost '%' include localhostPaul DuBois21 Feb
    • Re: Any way to make anyhost '%' include localhostJason Joines22 Feb
      • Re: Any way to make anyhost '%' include localhostPaul DuBois22 Feb