It is important to understand deeply mysql client access control.
Basically you need only one root account from the localhost for
Keep in mind that when you login specifying 'localhost' (either by the
-h flag or implicit) MySQL will use the mysql client socket interface,
if you specify '127.0.0.1' it will use the TCP/IP port (3306).
'localhost' is a sort of keyword telling the client to use the unix
socket file, '127.0.0.1' is bound to the tcp/ip port.
Host matching is always done BEFORE user matching.
MySQL sorts HOSTS with more specific entries on top and less ones on
bottom ('%' wildcarded entries)
MySQL sorts USERS with more specific entries on top and less ones on
bottom ('' empty user)
Bottom line, you need a triplet of USER-HOST-PASS for each account.
having localhost AND 127.0.0.1 it is only related to the different
connection method (socket , tcpip)
for any other (remote) account tcp-ip will be used.
I don't know if you are now more ore less confused!
Carlos Williams wrote:
> Can someone please explain why I have 3 entries for root or if this is
> normal behavior for MySQL? I thought after a installation of MySQL,
> you normally have 2:
> 1 - localhost
> 2 - host.domain.com
> For some reason I had a 3rd entry:
> 3 - 127.0.0.1
> I don't know if I did the right thing but I ran the following command:
> update user set host="localhost" where host='127.0.0.1';
> This basically changed the 127.0.0.1 entry in mysql databased, host
> section to localhost.
> I am not sure if MySQL needs to have the 3rd host entry for root that
> equals 127.0.0.1 or if it generally should just have the localhost and
> Can anyone please clear this up for me?