Is there any whoami function or command in MySQL like UNIX?


There is no whoami function in MySQL. The whoami can be used to know the current user in UNIX. Use user() or current_user() function from MySQL for the same purpose.

The following is the output.

+-----------+
| version() |
+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.00 sec)

Case 1  −Using CURRENT_USER() function.

The query to know the current user is as follows.

mysql> select current_user();

The following is the output.

+----------------+
| current_user() |
+----------------+
| root@%         |
+----------------+
1 row in set (0.00 sec)

Case 2 − Using USER() function.

The query is as follows −

mysql> select user();

The following is the output.

+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

Updated on: 25-Jun-2020

530 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements