Mysql Current_user Function

MySQL: CURRENT_USER Function

This tutorial explains how to use the MySQL CURRENT_USER function with syntax and examples.

Description

The MySQL CURRENT_USER function returns the user name and host name for the MySQL account that was used by the server to authenticate the current client.

Syntax

The syntax for the CURRENT_USER function in MySQL is:

CURRENT_USER( )

Parameters or Arguments

There are no parameters or arguments for the CURRENT_USER function in MySQL.

Note

Applies To

The CURRENT_USER function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0.6

Example

Let's look at some MySQL CURRENT_USER function examples and explore how to use the CURRENT_USER function in MySQL.

For example:

mysql> SELECT CURRENT_USER();

This CURRENT_USER function example would return the user name and host name for the MySQL account that the server used to authenticate the current client.

So if the MySQL account that was used by the server to authenticate the current client was 'root' and the host name was 'localhost':

mysql> SELECT USER();
Output: 'root@localhost'