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:
|