ID EN
Information Functions

USER()

MySQL 8.4

Returns the current MySQL user name and host name as a string in the utf8mb3 character set.

Syntax

MYSQL
SELECT USER();
'davida@localhost'

Examples

Example

The value indicates the user name you specified when connecting to the server, and the client host from which you connected. The value can be different from that of CURRENT_USER().

MYSQL
SELECT USER();
'davida@localhost'
Example 2

This function can be used for the default value of a VARCHAR or TEXT column, as shown in the following CREATE TABLE statement:

MYSQL
CREATE TABLE t (c VARCHAR(288) DEFAULT (USER()));