Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple text console session open and log in as different users into different consoles. I forget after while which consoles belong to which user, it would be nice to not have to quit and log back in.

How do I see which user I am logged in as?

Is there a way to change which user I logged in as with out logging out?

share|improve this question
up vote 25 down vote accepted

Actually, you need to use two functions


USER() reports how you attempted to authenticate in MySQL

CURRENT_USER() reports how you were allowed to authenticate in MySQL

Sometimes, they are different

share|improve this answer
eg. if you login to mysql via mysql -ulalala where lalala user doesn't exist, you will be allowed to login as 'anonymous' mysql user, namely ''@'localhost'. In this case returns of functions would be USER()= lalala@localhost and CURRENT_USER() = @localhost – Dimitry K Jan 27 '15 at 14:23
@DimitryK When that happens, you can run SHOW GRANTS; to see what permissions you have. Even if you see nothing except USAGE, you still need to be aware that certain test databases are 100% accessible to an anonymous user. See my post MySQL : Why are there “test” entries in mysql.db? ( – RolandoMySQLDBA Jan 27 '15 at 14:38
+1 for SHOW GRANTS, strange that I haven't stumbled upon it though reading numerous Mysql Tutorials. – Dimitry K Jan 27 '15 at 15:18


select user();


I pinched it from the 3rd google result for 'mysql whoami':

share|improve this answer

I found this user() function

select user(); Will show you which user is logged in.

share|improve this answer
Does that link still work for you? I decided to link to google's cache because of the mysql -> oracle breakage. – PriceChild Apr 5 '11 at 8:00
It does work, it has an other interesting function as well select database(); will show you your currently selected database. – nelaar Apr 5 '11 at 8:07
That's really annoying, I wonder why it doesn't work for me. Thanks. – PriceChild Apr 5 '11 at 8:08
@pricechild… – nelaar Apr 5 '11 at 8:21
Nope, sends me to… – PriceChild Apr 5 '11 at 8:30

You can use 'status':

MariaDB [my_database]> status

Current user: root@localhost

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.