Open In App

MySQL | USER( ) Function

Last Updated : 19 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The MySQL USER() function is used for returning the current user name and host name for the MySQL connection being used by the user. This function uses the utf8 character set. The USER() function does not require any parameter to be passed.

The user name returned by the USER() function is the name of the user specified when connecting to the server whereas the host name returned by the USER() function is the name of the client host that the user uses to establish a connection from. The USER() function is similar to the SESSION_USER() function and the SYSTEM_USER() function.

Syntax:

USER()

Parameters Used:
It does not require any parameter or argument to be passed.

Return Value:
The MySQL Version() function returns the version of the MySQL database as a string.

Supported Versions of MySQL:

  • 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: Implementing USER() function in MySQL.

SELECT USER(); 

Output:

author@gfg 

Previous Article
Next Article

Similar Reads

Set Database From Single User Mode to Multi User in SQL
A single-user mode specifies that only one user at a time can access the database. If you set the database to single-user mode then all other connections will be closed without warning. If you get disconnected after setting the database into single-user mode, a different user can connect to database, but only one user. Where as in multiple-user mod
4 min read
MySQL | CREATE USER Statement
MySQL allows us to specify which user account can connect to a database server. The user account details in MySQL contains two information - username and host from which the user is trying to connect in the format username@host-name. If the admin user is connecting through localhost then the user account will be admin@localhost. MySQL stores the us
3 min read
MySQL | Change User Password
In MySQL, the user account password can be changed using 3 different statements: UPDATE statement SET PASSWORD statement ALTER USER statement. But before changing the password of an account, two very important things should be kept in mind: The user account details for which you want to change the password. The application is being used by the user
2 min read
MySQL | DROP USER
The DROP USER statement in MySQL can be used to remove a user account along with its privileges from the MySQL completely.But before using the drop user statement, the privileges of the user should be revoked or in other words, if a user has no privileges then the drop user statement can be used to remove a user from the Mysql database server. Synt
2 min read
MySQL | RENAME USER
The RENAME USER statement can be used in MySQL if a MySQL administrator wants to change the username or the host of an existing MySQL user account without altering the user account's privileges. Syntax : RENAME USER 'username'@'host' TO 'new_username'@'host'; Parameters Used: Username: It is the username of the user account you want to rename. new_
1 min read
Mysql | User-defined Variables
Mysql also supports the concept of User-defined variables, which allows passing of a value from one statement to another. A user-defined variable in Mysql is written as @var_name where, var_name is the name of the variable and can consist of alphanumeric characters, ., _, and $. A user-defined variable is session specific i.e variable defined by on
3 min read
How to Add an Admin User to WordPress Database via MySQL?
Sometimes you get denied from accessing your WordPress dashboard due to various reasons. One of the reasons is that your website gets hacked or you forget your user id and password in the admin area. And another reason may be that the WordPress website gets broken or maybe some other technical issue. To access your WordPress Admin dashboard area ag
5 min read
Encryption and Schema Binding Option in User Defined Function
Encryption and schema binding are two separate options that can be applied to user-defined functions in SQL Server. Encryption:When you create a user-defined function in SQL Server, you can choose to encrypt the function's definition. This means that the source code of the function will be stored in an encrypted format, making it more difficult for
2 min read
MySQL | LEAD() and LAG() Function
The LEAD() and LAG() function in MySQL are used to get preceding and succeeding value of any row within its partition. These functions are termed as nonaggregate Window functions. The Window functions are those functions which perform operations for each row of the partition or window. These functions produce the result for each query row unlikely
3 min read
MySQL | BIN() Function
The BIN() function in MySQL is used to convert a decimal number to its binary equivalent.The BIN() function is equivalent to the CONV() function written in the format CONV(number,10,2). In this format CONV() function converts the number 'number' from base 10(decimal) to base 2(binary). It is important to note that the BIN() function can only be use
1 min read
Article Tags :