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() |
+----------------+
| root@% |
+----------------+
The CURRENT_USER()
and USER()
function may be have different return values, as follows:
SELECT CURRENT_USER(), USER();
Output:
+----------------+--------------------+
| CURRENT_USER() | USER() |
+----------------+--------------------+
| root@% | [email protected] |
+----------------+--------------------+
Here, the CURRENT_USER()
function returns the username and hostname that the MariaDB server uses to authenticate the current client’s MariaDB account, and the USER()
function returns the username and hostname of the current MariaDB account.
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.