NYCPHP Meetup

NYPHP.org

[nycphp-talk] different sites, one database

Tim Gales tgales at tgaconnect.com
Thu Jul 14 09:01:55 EDT 2005


David Mintz writes:
> ...
> answer to a question similar to this one. I have gotten what I thought was
> screwy behavior when there were rows in mysql.user that had the same value
> for user but different values for host. Connection from one host would
> work but not the other, as thought the first matching row mysql encounters
> were overshadowing the second.
> 
> Can you or can you not have two users 'foo', one of which has host 'host1'
> and the other of which has 'host2' and have both be able to connect from
> their respective hosts? (And I am talking about doing this through GRANT
> statements rather than updating the user table directly).
> 
Yes.

(see 5.6.5. Access Control, Stage 1: Connection Verification in
the manual)

" It is a common misconception to think that, for a given username, all 
entries that explicitly name that user are used first when the server 
attempts to find a match for the connection."

"f you are able to connect to the server, but your privileges are not 
what you expect, you probably are being authenticated as some other 
account. "

Basically MySQL orders the host user combination from the most
specific (restrictive) to the most general (like entries with
  wildcard characters)

It uses the first combination which would allow a connection.

This can cause uexpected results if you login successfully
under a different authentication record than you were
meaning to.

The manual suggests using 'CURRENT_USER()' to help explain
what's happening.

-- 
T. Gales & Associates
'Helping People Connect with Technology'

http://www.tgaconnect.com



More information about the talk mailing list