MariaDB CURRENT_USER() Function
In MariaDB, CURRENT_USER() is a built-in function that returns the username and hostname of the MariaDB account that the MariaDB server uses to authenticate the current client.
MariaDB CURRENT_USER() Syntax
Here is the syntax of the MariaDB CURRENT_USER() function:
CURRENT_USER
CURRENT_USER()
Parameters
The MariaDB CURRENT_USER() function do not require any parameters.
Return value
The MariaDB CURRENT_USER() function returns a UTF8 string that is the username and hostname that the MariaDB server uses to authenticate the current client’s MariaDB account.
The MariaDB CURRENT_USER() function is similar to the USER() function, but their values may be different. The USER() function returns the current username and hostname.
MariaDB CURRENT_USER() Examples
The following example shows how to use the CURRENT_USER() function to get current user information.
SELECT CURRENT_USER();
Output:
+----------------+
| 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.
Conclusion
In MariaDB, CURRENT_USER() is a built-in function that returns the username and hostname of the MariaDB account that the MariaDB server uses to authenticate the current client.