0

Output of SHOW GRANTS FOR ''@'localhost';

GRANT USAGE ON *.* TO ''@'localhost'

However, when I log in using my default user account, which is later defaulted to an annonymous account by mySQL as shown below :

Output of SELECT USER(),CURRENT_USER();

+------------------+-------------------+
| USER()           | CURRENT_USER()    |
| dukn@localhost   | @localhost        |
+------------------+-------------------+

I can still do show databases; using @localhost. Why is this so ?

UPDATE:

Output of @@version : 5.5.34-0ubuntu0.13.10.1

Output of show grants while logged in as dukn@localhost : GRANT USAGE ON *.* TO ''@'localhost'

iridescent
  • 103
  • 4
  • Are you saying you can run SHOW DATABASES; and see the list of databases? Or does it return nothing (but no error)? Please add the output of SHOW GRANTS; while logged in as the user in question (as opposed to SHOW GRANTS FOR...). Also please include SELECT @@VERSION;. – Michael - sqlbot Jan 19 '14 at 16:07
  • @Michael-sqlbot Yes, SHOW DATABASES; still shows the list of databases. Updated the post. – iridescent Jan 20 '14 at 02:21

1 Answers1

0

I just ran this in MySQL 5.6.15 on my Windows 8 machine

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user(),current_user();
+----------------+----------------+
| user()         | current_user() |
+----------------+----------------+
| ODBC@localhost | @localhost     |
+----------------+----------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.05 sec)

mysql>

Then, I logged into MySQL as redwards@localhost

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user(),current_user();
+--------------------+--------------------+
| user()             | current_user()     |
+--------------------+--------------------+
| redwards@localhost | redwards@localhost |
+--------------------+--------------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql>

What is the difference? An anonymous user can still execute SHOW DATABASES; but can only see information_schema (contains metadata only anonymous users can see). Why can the database test be seen? The table mysql.db allows test databases to be visible to everyone (See my question MySQL : Why are there "test" entries in mysql.db? and the answer I posted)

RolandoMySQLDBA
  • 182,700
  • 33
  • 317
  • 520