MySQL: USER Function

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

In this guide, we will explain how to use the MySQL USER function with syntax and examples.

Description

The MySQL USER function returns the user name and host name for the current MySQL user.

Syntax

The syntax for the USER function is:

USER( )

Parameters or Arguments

There are no parameters or arguments for the USER function.

Note

  • The user name returned is the name of the user specified when connecting to the server.
  • The host name returned is the name of the client host that the user connected from.
  • The SESSION_USER and SYSTEM_USER functions are synonyms for the USER function.
  • See also the CURRENT_USER function which can return a different value than the USER function.

Applies To

The USER function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some USER function examples and explore how to use the USER function.

For example:

mysql> SELECT USER();

This USER function example would return the user name and host name for the current MySQL user.

So if the user name specified when connecting to the server was ‘root’ and the name of the client host that the user connected from was ‘imac.adglob.in:

mysql> SELECT USER();
Result: 'root@imac.adglob.in'

Next Topic : Click Here

This Post Has One Comment

Leave a Reply