Running SELECT USER(),CURRENT_USER(); on
Ubuntu 18.04 mariadb 10.4.
i'm not sure why when logging (even with -h) in I'm getting root@% not [email protected] me from adding user.
| USER() | CURRENT_USER() |
---------------- ----------------
| root@localhost | root@% |
CodePudding user response:
You are logging in as the user root from the host localhost, and that is matching the user root connecting from an arbitrary host. You can look at how you set up this user with:
show grants for root@`%`;
You can check if there are also grants for root@localhost user with:
show grants for root@localhost;
CodePudding user response:
USER() shows the login name which is provided by the client for to be authenticated plus hostname detected by MySQL server where the client is connecting from.
CURRENT_USER() shows the account name which was selected from all ones matched to the name provided by the client and detected host.
You cannot manage this selection.
If you connects from the localhost and needs root@localhost to be used for authentication then use socket, not IP, connection type.
If you connects from another host, not from localhost, then root@localhost cannot be used for authentication because it does not match.
