MySQL CURRENT_USER() Function
The MySQL CURRENT_USER() function returns the user name and host name for the MySQL account that was used by the server to authenticate the current client. This function uses the UTF8 character set.
Note that, the CURRENT_USER() function can return a different value than the USER() function.
The SESSION_USER() and SYSTEM_USER() functions are synonyms for the USER() function.
Syntax
CURRENT_USER()
Parameters
No parameter is required.
Return Value
Returns the user name and host name for the current MySQL user.
Example:
The example below shows the usage of CURRENT_USER() function.
mysql> SELECT CURRENT_USER();
The above query will return the user name and host name for the MySQL account that the server used to authenticate the current client. Therefore if the MySQL account that was used by the server to authenticate the current client was 'root' and the host name was 'localhost', it will return the following:
mysql> SELECT CURRENT_USER(); Result: 'root@localhost'
❮ MySQL Functions