ID EN
Information Functions

CURRENT_USER

MySQL 8.4

CURRENT_USER, CURRENT_USER()

Syntax

MYSQL
SELECT USER();
'davida@localhost'
SELECT * FROM mysql.user;
ERROR 1044: Access denied for user ''@'localhost' to
database 'mysql'
SELECT CURRENT_USER();
'@localhost'

Examples

Example

Returns the user name and host name combination for the MySQL account that the server used to authenticate the current client. This account determines your access privileges. The return value is a string in the utf8mb3 character set.

MYSQL
SELECT USER();
'davida@localhost'
SELECT * FROM mysql.user;
ERROR 1044: Access denied for user ''@'localhost' to
database 'mysql'
SELECT CURRENT_USER();
'@localhost'
Example 2

The value of CURRENT_USER() can differ from the value of USER().

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