This explains how MySQL decides which user to log in when there are two with the same name.
\!h Example - conflicting name and host name:
GRANT SELECT ON music.* TO 'dave'@'%' IDENTIFIED BY 'password'; -- can connect from any location
GRANT ALL ON music.* TO 'dave'@'localhost' IDENTIFIED BY 'password'; -- same name, can only connect from localhost
-- because the first user can connect from any location, that includes the second user's localhost
\!h How does MySQL determine which user logs in?
-- It sorts the user entries by host from most to least specific, and for duplicate hosts, any anonymous entry appears last.
-- Also, MySQL will also establish the connection based on connection requirements and if access is granted. i.e matching username and host name