MariaDB SYSTEM_USER() Function
In MariaDB, SYSTEM_USER() is a built-in function that returns the username and hostname of the current MariaDB account.
SYSTEM_USER() and SESSION_USER() are synonyms for the USER() function.
MariaDB SYSTEM_USER() Syntax
Here is the syntax of the MariaDB SYSTEM_USER() function:
SYSTEM_USER()
Parameters
The MariaDB SYSTEM_USER() function do not require any parameters.
Return value
The MariaDB SYSTEM_USER() function returns a UTF8 string that is the username and hostname of the current MySQL account.
MariaDB SYSTEM_USER() Examples
The following example shows how to use the SYSTEM_USER() function to get the current user information.
SELECT SYSTEM_USER();
Output:
+----------------+
| SYSTEM_USER() |
+----------------+
| root@localhost |
+----------------+SYSTEM_USER() vs CURRENT_USER()
SYSTEM_USER() is different from CURRENT_USER(). CURRENT_USER() returns the username and hostname of the MariaDB account that the MariaDB server uses to authenticate the current client.
SELECT
CURRENT_USER(),
SYSTEM_USER();
Output:
+----------------+----------------+
| CURRENT_USER() | SYSTEM_USER() |
+----------------+----------------+
| root@% | root@localhost |
+----------------+----------------+In this example, CURRENT_USER() returns root@% and SYSTEM_USER() returns root@localhost.
Conclusion
In MariaDB, SYSTEM_USER() is a built-in function that returns the username and hostname of the current MariaDB account.