0

I'd love to know why when you first install MySQL on a server there are three root users entered into the users table each with different host addresses. One with localhost one with 127.0.0.1 and one with ::1 (for IPv6).

I don't really understand why all three are necessary. Will it enhance security to delete the root@localhost & root@::1 and only leave root@127.0.0.1 with access? Would that be a good thing to do or not? If not, what are the other host addresses used for?

NB: I'm running MySQL on an ubuntu based server.

0
3

As far as MySQL is concerned a connection from 127.0.0.1 is different from a connection from ::1 so if you want to access the server from either protocol you need to allow it. The localhost entry is there to allow connections via a socket connection rather than a tcp connection so

mysql -h 127.0.0.1 -u user -p
mysql -h ::1 -u user -p
mysql -h localhost -u user -p 

are all different connections. Using

mysql -h localhost  -u user -p -e 'show full processlist\G;'
...
User: user
Host: localhost
...

and

mysql -h localhost  --protocol=tcp -u user -p -e 'show full processlist\G;'
...
User: user
Host: localhost:60249
...

Note the port number 60249 which shows it's a TCP connection.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.