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?


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

  • 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
  • 2
    @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? (dba.stackexchange.com/q/13361/877) – 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

I found this user() function

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

  • Does that link still work for you? I decided to link to google's cache because of the mysql -> oracle breakage. – Pricey 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. – nelaaro Apr 5 '11 at 8:07
  • That's really annoying, I wonder why it doesn't work for me. Thanks. – Pricey Apr 5 '11 at 8:08
  • @pricechild dev.mysql.com/doc/refman/5.5/en/… – nelaaro Apr 5 '11 at 8:21
  • Nope, sends me to search.oracle.com/search/… – Pricey Apr 5 '11 at 8:30


select user();


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


You can use 'status':

MariaDB [my_database]> status

Current user: root@localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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