Knowledge Walls
John Peter
Pune, Maharashtra, India
How to check logged-in user in Mysql? in Computer software engineer articles of One day One Thing to Know
1502 Views
Example
SELECT USER();
Or
SELECT CURRENT_USER();
Hints 
CURRENT_USER AND USER functions are returns the same output. Both returns username and host of the user.

Example
root@localhost

root is the username. localhost is the domain of the user. It returns depends upon the login credentials. These credentials are available at mysql.user table.
Running style 
mysql_pro: mysql -u root -p
Enter password: *****
Welcome to the MySQL monitor.

mysql> SELECT USER();
+----------------+
| USER()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> exit;
Bye

mysql_pro:
Best Lessons of "One day One Thing to Know"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details