Bug #70030 current_user does not reflect expected value
Submitted: 14 Aug 2013 9:27 Modified: 21 Jul 2014 12:14
Reporter: Oli Sennhauser Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S3 (Non-critical)
Version:5.6.12 OS:Any
Assigned to: CPU Architecture:Any
Tags: current_user

[14 Aug 2013 9:27] Oli Sennhauser
Description:
When we connect with user root@127.0.0.1 current_status()/status does not reflect expected value but root@localhost.
When root@localhost is dropped then it does show the expected value. This looks a bit strange.
skip-name-resolve solves the problem. But IMHO it should work anyway...
Possibly this is not considered to be a bug but it looks at least strange to me.

How to repeat:
mysql> select user, host from mysql.user where user = 'root';
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+

mysql> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+

mysql> show grants for root@'127.0.0.1';
+---------------------------------------------------------------------+
| Grants for root@127.0.0.1                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION |
+---------------------------------------------------------------------+

shell> mysql --user=root --host=localhost

mysql> status;
Current user:           root@localhost
Connection:             Localhost via UNIX socket

mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+

shell> mysql --user=root --host=127.0.0.1
Current user:           root@localhost
Connection:             127.0.0.1 via TCP/IP

mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+

mysql> drop user root@localhost;

mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+

shell> mysql --user=root --host=127.0.0.1
mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@127.0.0.1 |
+----------------+

Suggested fix:
last value should already be shown in the beginning.
[21 Jul 2014 12:14] Sveta Smirnova
Thank you for the report.

Verified as described.