Below is the result of the query select host, user from mysql.user from a fresh installed MySQL 5.
+-----------+------------------+
| host | user |
+-----------+------------------+
| 127.0.0.1 | root |
| localhost | debian-sys-maint |
| localhost | root |
| ubuntu | root |
+-----------+------------------+
127.0.0.1, localhost, and ubuntu all point to the same machine, which is the local host. I can’t find any difference after removing the rows with the seemingly duplicate host/user pairs from the table.
What’s the difference between these? Can I safely remove the other two?
From the manual:
And:
However, I can’t find any rationale for this. There’s nothing elsewhere in the manual that suggests that this is required for any particular reason, but presumably it’s to cover all the bases for request verification. There may be some instances where one originating local connection uses one account whilst others require use alternatives; I guess it was decided that ensuring local root access will always work, no matter what the edge case, was a good thing.