Try the CURRENT_USER() function. This returns the username that MySQL used to authenticate your client connection. It is this username that determines your privileges.
This may be different from the username that was sent to MySQL by the client (for example, MySQL might use an anonymous account to authenticate your client, even though you sent a username). If you want the username the client sent to MySQL when connecting use the USER() function instead.
The value indicates the user name you specified when connecting to the server, and the client host from which you connected. The value can be different from that of CURRENT_USER().
It can sometimes be different, USER() will return by which login you attempted to authenticate and CURRENT_USER() will return how you were actually allowed to authenticate.
I needed such a feature and i used CURRENT_USER() but that gave me the Global Admin user which happens to be same for every query even if i changed the query username when connecting to the database.
Obviously that is useless in the use case i was looking for.
Then I used USER() and it gave me the username of the connection string that initiated the query.
if i understood the question, this is what the person wanted in plain language. In my case, i used it in a trigger to track changes made to rows in a transaction table.