It came up twice in two days: if you do not specify the user name when connecting, what gets picked?
The manual says:
"On Unix, most MySQL clients by default try to log in using the current Unix user name as the MySQL user name, but that is for convenience only."
"The default user name is ODBC on Windows or your Unix login name on Unix."
Let's be a little more specific. The relevant section of code is in libmysql/libmysql.c
On Linux, we check the following in this order:
- if (geteuid() == 0), user is "root"
- environment variables $USER, $LOGNAME, $LOGIN
If none of those return non-NULL results, use "UNKNOWN_USER"
- environment variable $USER
If that's not set, use "ODBC".
I wondered why on Windows we check $USER but not $USERNAME. I gather that it's an ODBC thing.