MySQL: CURRENT_USER Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL CURRENT_USER Function

In this guide, we will explain 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

  • The CURRENT_USER function uses the utf8 character set.
  • See also the USER function which can return a different value than the CURRENT_USER function.
  • The SESSION_USER and SYSTEM_USER functions are synonyms of the USER function.

Applies To

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

  • 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 CURRENT_USER function examples and explore how to use the CURRENT_USER function.

For example:

mysql> SELECT CURRENT_USER();

This CURRENT_USER function example would return the user name and host name for the 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();
Result: 'root@localhost'

Next Topic : Click Here

This Post Has One Comment

Leave a Reply