how do I see which user I am logged in as in MySQL?
60,444
Solution 1
Actually, you need to use two functions
SELECT USER(),CURRENT_USER();
USER() reports how you attempted to authenticate in MySQL
CURRENT_USER() reports how you were allowed to authenticate in MySQL
Sometimes, they are different
Solution 2
I found this user() function
select user(); Will show you which user is logged in.
Solution 3
You can use 'status':
MariaDB [my_database]> status
Current user: root@localhost
Related videos on Youtube
Author by
nelaaro
Linux admin, tech enthusiast. opensource evangelist.
Updated on September 18, 2022Comments
-
nelaaro over 1 year
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?
-
Pricey about 13 yearsDoes that link still work for you? I decided to link to google's cache because of the mysql -> oracle breakage.
-
nelaaro about 13 yearsIt does work, it has an other interesting function as well select database(); will show you your currently selected database.
-
Pricey about 13 yearsThat's really annoying, I wonder why it doesn't work for me. Thanks.
-
Pricey about 13 yearsNope, sends me to search.oracle.com/search/…
-
nelaaro about 13 years@pricechild which browser are you using. I use google chrome it works perfectly. I wander where the redirection is coming from.
-
Dimitry K over 9 yearseg. if you login to mysql via
mysql -ulalala
wherelalala
user doesn't exist, you will be allowed to login as 'anonymous' mysql user, namely''@'localhost'
. In this case returns of functions would beUSER()= lalala@localhost
andCURRENT_USER() = @localhost
-
Dimitry K over 9 years+1 for
SHOW GRANTS
, strange that I haven't stumbled upon it though reading numerous Mysql Tutorials.