MySQL CURRENT_USER() Function
The MySQL CURRENT_USER() function returns the username and hostname of the MySQL account that the MySQL server uses to authenticate the current client.
CURRENT_USER() Syntax
Here is the syntax of the MySQL CURRENT_USER() function:
CURRENT_USER()
or
CURRENT_USER
Parameters
The MySQL CURRENT_USER() function does not require any parameters.
Return value
The CURRENT_USER() function returns a UTF8 string that is the username and hostname used by the MySQL server to authenticate the current client’s MySQL account.
The CURRENT_USER() function are similar to the USER() function, but their values may be different. The USER() function returns the current username and hostname.
CURRENT_USER() Examples
The following example shows how to use the current user information using the CURRENT_USER() function.
SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| app@localhost |
+----------------+For this illustrative local account, CURRENT_USER() returns app@localhost. It reports the account row used for authentication and privilege checks. It can differ from USER() when the server authenticates a connection as a different account. See the official account authentication documentation.