Get the current user in MySQL Get the current user's MySQL username, no hostname required
P粉3402642832024-03-27 08:31:44
0
1
362
I know that we can use the user() and current_user() functions to get the currently logged in user. But I only need users without hostname suffix. I can't seem to find any reference to the built-in MySQL function that just provides a username.
You can use SUBSTRING_INDEX to return the string before the character (in this case "@")
So basically this way you avoid anything that is not the user part of current_user()