©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The CURRENT_USER SQL Function in MySQL and MariaDB - Client host and username

CURRENT_USERSyntax:CURRENT_USER()
Return value:CHAR
Function type:Information function
Function Description

The CURRENT_USER() function returns the current username and hostname that the server used to authenticate the current client.

This account determines the access rights.

The value of CURRENT_USER() may differ from the value of USER(), SYSTEM_USER() and SESSION_USER().

SQL Examples for the CURRENT_USER function

 1
 2
 3

SELECT current_user();

current_user()
varchar(288) BINARY
root@localhost
The examples were created with the MyWAY SQL manager: Download

How to use the CURRENT_USER() function in MySQL and MariaDB databases

In MySQL and MariaDB the CURRENT_USER() function is used to get the current combination of username and host for the database connection and return it as a string. The function requires no arguments and can be used directly in SQL statements or within SQL queries.

The function can be used to determine the current user connected to the database so that authentication and authorization logic can be implemented based on the user's identity. CURRENT_USER() can be used for monitoring or logging purposes to allow tracking of user activity within the database. The retrieved user information can also be used in conditional statements or queries to perform various actions based on the user's identity, such as assigning specific logic or permissions to different users or groups of users.

The returned username and host combination may depend on the specific authentication mechanisms used by database servers. For security reasons, the username can be an encrypted or obfuscated representation.
CURRENT_ROLECURRENT_TIMECURRENT_TIMESTAMPCURRENT_USERCURTIMEDATABASEDATE

Further MySQL und MariaDB SQL Information functions

BENCHMARKBENCHMARK(Number, Expression)
More about BENCHMARK Function

BINLOG_GTID_POSBINLOG_GTID_POS()

CHARSETCHARSET(String)
More about CHARSET Function

COERCIBILITYCOERCIBILITY(String)
More about COERCIBILITY Function

COLLATIONCOLLATION(String)
More about COLLATION Function

CONNECTION_IDCONNECTION_ID()
More about CONNECTION_ID Function

CURRENT_ROLECURRENT_ROLE()
More about CURRENT_ROLE Function

DATABASEDATABASE()
More about DATABASE Function

DECODE_HISTOGRAMDECODE_HISTOGRAM()

DEFAULTDEFAULT(Column)
More about DEFAULT Function

FOUND_ROWSFOUND_ROWS()
More about FOUND_ROWS Function

LAST_INSERT_IDLAST_INSERT_ID([Expression])
More about LAST_INSERT_ID Function

LAST_VALUELAST_VALUE(Expression [, Expression ...])
More about LAST_VALUE Function

ROWNUMROWNUM()

ROW_COUNTROW_COUNT()
More about ROW_COUNT Function

SCHEMASCHEMA()
More about SCHEMA Function

SESSION_USERSESSION_USER()
More about SESSION_USER Function

SYSTEM_USERSYSTEM_USER()
More about SYSTEM_USER Function

USERUSER()
More about USER Function

VERSIONVERSION()
More about VERSION Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the CURRENT_USER SQL function: mysql.com and mariadb.com
Updated: 2023-09-17ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer