Is there a way to know your current username in mysql?

I would like to know if there's a way for a mysql query to return the username of the user that issues the query.

Is this possible?


Try to run either

SELECT USER();

or

SELECT CURRENT_USER();

It can sometimes be different, USER() will return by which login you attempted to authenticate and CURRENT_USER() will return how you were actually allowed to authenticate.


Try the CURRENT_USER() function. This returns the username that MySQL used to authenticate your client connection. It is this username that determines your privileges.

This may be different from the username that was sent to MySQL by the client (for example, MySQL might use an anonymous account to authenticate your client, even though you sent a username). If you want the username the client sent to MySQL when connecting use the USER() function instead.

The value indicates the user name you specified when connecting to the server, and the client host from which you connected. The value can be different from that of CURRENT_USER().

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_current-user


Use this query:

SELECT USER();

Or

SELECT CURRENT_USER;

You can use:

SELECT USER();

or

SELECT CURRENT_USER();

See more here http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_current-user


to print the current user who is using the database

select user();

or

select current_user();