In mysql
's general log I see things like:
141017 8:57:31 4 Connect root@localhost as anonymous on
What is this "as anonymous on" thing even means? I log in as root@localhost
. Am I still anonymous, or even "anonymous on"?
UPD
$ systemctl stop mysqld
$ rm -f /var/lib/mysql/yuri.log
// enable general log in /etc/mysql/my.cnf
$ systemctl start mysqld
$ mysql -u root -p -BNe 'SELECT USER() HowYouAttemptedToLogin, CURRENT_USER() HowMySQLAllowedYouToLogin;'
Enter password:
root@localhost root@localhost
$ mysql -u root -p -BNe 'SELECT host, user FROM mysql.user;'
Enter password:
127.0.0.1 root
::1 root
localhost hostname
localhost root
$ cat /var/lib/mysql/yuri.log
/usr/bin/mysqld, Version: 10.0.14-MariaDB-log (MariaDB Server). started with:
Tcp port: 3306 Unix socket: /run/mysqld/mysqld.sock
Time Id Command Argument
141204 19:03:19 3 Connect UNKNOWN_USER@localhost as anonymous on
3 Connect Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO)
141204 19:04:55 4 Connect root@localhost as anonymous on
4 Query select @@version_comment limit 1
4 Query SELECT USER() HowYouAttemptedToLogin, CURRENT_USER() HowMySQLAllowedYouToLogin
4 Quit
141204 19:05:47 5 Connect root@localhost as anonymous on
5 Query select @@version_comment limit 1
5 Query SELECT host, user FROM mysql.user
5 Quit
Best Answer
After some major league Googling all over the planet, I think I found the answer.
From these posts I saw something interesting
13679547 Connect @localhost as anonymous on test
140612 12:33:07 3 Connect gk_admin at localhost as anonymous on dTEST_db
My conjecture is the following: What follows
as anonymous on
is the currently connected databaseThe general log entry must say
as anonymous on mysql
The general log entry must say
as anonymous on test
The general log entry must say
as anonymous on
Give it a Try !!!
UPDATE 2014-12-04 14:26 EST
Are you ready for this? I have an old post where someone has the source code with
as anonymous on
log_warnings doesn't seem to work for aborted connections in MySQL 5.1
In the code from my 2-year-old post,
as anonymous on
is hardcoded !!!Look at the code again
Please note the part of the code that references the database
db ? db : (char*) "");
. Either thedb
variable (the current database) points to a database name or an empty string.The weird part about answering this question is that this is the second time I had to refer back to a post I myself wrote years ago. The first time was this: Does MySQL still handle indexes in this way?
UPDATE 2014-12-17 16:45 EST
Based on your last comment
In your question, you asked
What is this "as anonymous on" thing even means?
The answer I said wasEither the db variable (the current database) points to a database name or an empty string
. As forthd->main_security_ctx.user, thd->main_security_ctx.host_or_ip
, that would beroot@localhost
. What comes afteras anonymous
on is the current DB. This is nothing left to figure out.You then asked
Am I still anonymous, or even "anonymous on"?
. The answer would have to yes because you have been authenticated as a user of a DB Connection and your connection becomes an active thread like any other thread.Any connection
are all equal threads. The general log does not differentiate one DB Connection from another. The code checks all connections the same way regardless of connections being internal or external.
If what my answer has stated still does not answer your question, there is really one thing you can do: Go to the MySQL Forums and post this question to the Developers. Since
Konstantin Osipov
was the developer who was responding to the Bug List and refers to this source code (bugs.mysql.com/bug.php?id=24761) that uses the expressionas anonymous on
in thegeneral_log_print function
, he would have to know the correct context and reason for using the expressionas anonymous on
.UPDATE 2018-08-12 19:46 EDT
In ight of your conjecture, I went Googling around and found sample output from a general log:
Please look at both timestamp entries from the sample log:
as well as the original log entry from your question:
At these points in time, the user is not authenticated even though
root@localhost
appears. The comment for the code does support your conjecture. You now have the answer directly from the source code's author.Thank you for accepting my posted answer (which lead to you finding the real answer)