MariaDB CURRENT_USER(): Account and Privileges
See which MariaDB account CURRENT_USER() returns, compare it with USER(), and understand its DEFINER behavior in stored procedures.
On this page
MariaDB’s CURRENT_USER() returns the account name and host name the server used to authenticate the current client. That account determines the connection’s privileges. It can differ from USER(), which reports the identity provided by the client. See MariaDB’s CURRENT_USER() reference.
Syntax
CURRENT_USER
CURRENT_USER()
Both forms return the authenticated MariaDB account as a string in user@host form.
Check the privilege account
SELECT CURRENT_USER();
To compare the account used for privileges with the client-provided identity, select both values:
SELECT
USER() AS client_identity,
CURRENT_USER() AS privilege_account;
The values may differ when authentication or proxy-user mapping selects an account different from the one supplied by the client. Use CURRENT_USER() while investigating MariaDB account matching, and inspect that account’s grants when you need to understand access.
Stored procedure behavior
Inside a stored procedure, CURRENT_USER() returns the procedure’s DEFINER. Check the routine definition and its SQL security context before interpreting the result as the connected client’s account. It is not the operating-system user that runs the MariaDB server.
For the client identity, compare with USER(). SYSTEM_USER() is a synonym for USER(). SESSION_USER() has behavior that depends on the MariaDB version and compatibility mode.
Replication note
MariaDB lists statements that use CURRENT_USER() as unsafe for statement-based replication. See the official unsafe statements reference when using it in replicated data changes.