MySQL USER() Function

The MySQL USER() function returns the username and hostname of the current MySQL account.

The USER() function is equivalent to SYSTEM_USER() and SESSION_USER().

USER() Syntax

Here is the syntax of the MySQL USER() function:

USER()

Parameters

The MySQL USER() function does not require any parameters.

Return value

The USER() function returns a UTF8 string that is the username and hostname of the current MySQL account.

USER() Examples

The following example shows how to get the current user information using the USER() function.

SELECT USER();
+--------------------+
| USER()      |
+--------------------+
| [email protected] |
+--------------------+

Here, the username of the current user is root, and ths hostname of the current user is 192.168.0.204.