To extract only the username part : USER « Information Functions « MySQL Tutorial






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

mysql>








20.15.USER
20.15.1.USER() returns the current MySQL username and hostname
20.15.2.To extract only the username part