Bug #36019 Authentication issue depending on input redirection
Submitted: 12 Apr 2008 19:57 Modified: 13 Jun 2008 13:21
Reporter: Olaf van der Spek (Basic Quality Contributor) Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0.51a-3 (Debian) OS:Linux (Debian Testing)
Assigned to: CPU Architecture:Any
Tags: qc

[12 Apr 2008 19:57] Olaf van der Spek
Description:
A: olaf@debian:~/xf3$ mysql -u root -D xf3 < xcc_forum.sql 
B: olaf@debian:~/xf3$ mysql -D xf3 < xcc_forum.sql 
ERROR 1045 (28000): Access denied for user 'olaf'@'localhost' (using password: NO)
C: olaf@debian:~/xf3$ mysql -D xf3
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 46
Server version: 5.0.51a-3 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit
Bye
olaf@debian:~/xf3$ 

I don't have a .my.cnf file.
I'm wondering why C doesn't fail. There is no MySQL user 'olaf' and C somehow logs in as MySQL user 'root' (for which no password is required).

How to repeat:
?
[16 Apr 2008 16:01] Susanne Ebrecht
$ ./bin/mysql -u nonexist
mysql> show grants;
+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' | 
+--------------------------------------+

$ ./bin/mysql -u myuser
mysql> show grants;
+-----------------------------------------------------------------------+
| Grants for miracee@localhost                                          |
+-----------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'localhost' WITH GRANT OPTION | 
+-----------------------------------------------------------------------+

That you can connect with "-u someone" without having an account for "someone" is an expected behaviour.

"someone" can connect but he/she has only rights for using the system and no rights for doing something else on the system.

Please also read:
http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html
[16 Apr 2008 16:14] Olaf van der Spek
> "someone" can connect but he/she has only rights for using the system and no 
> rights for doing something else on the system.

Wouldn't it say "access denied to database 'xf3'" in that case?
[19 Apr 2008 15:21] Olaf van der Spek
Reopening...
[19 Apr 2008 15:25] Olaf van der Spek
olaf@debian:~/xf3$ mysql -D xf3 < xcc_forum.sql 
ERROR 1045 (28000): Access denied for user 'olaf'@'localhost' (using password: NO)
olaf@debian:~/xf3$ mysql -D xf3
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.0.51a-3 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | 
+---------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>
[25 Apr 2008 13:00] Sveta Smirnova
Thank you for the report.

Have you upgraded before starting to experience such issues? Could you also please provide output of SELECT USER(), CURRENT_USER() after interactive login.
[25 Apr 2008 19:21] Olaf van der Spek
No, this is on a clean install of Debian Testing.

olaf@dhcppc4:~$ touch xcc_forum.sql
olaf@dhcppc4:~$ mysql -D xf3 < xcc_forum.sql 
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'xf3'
olaf@dhcppc4:~$ mysql -D xf3
ERROR 1049 (42000): Unknown database 'xf3'
olaf@dhcppc4:~$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51a-3 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database xf3;
Query OK, 1 row affected (0.00 sec)

mysql> exit
Bye
olaf@dhcppc4:~$ mysql -D xf3 < xcc_forum.sql 
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'xf3'
olaf@dhcppc4:~$ mysql -D xf3
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.51a-3 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

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

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

mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | 
+---------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> exit
Bye
olaf@dhcppc4:~$
[13 May 2008 13:21] Sveta Smirnova
Thank you for the feedback.

We still can not repeat described behavior. Could you please try with generic Linux binaries which MySQL provides to see if this MySQL or Debian build issue?
[13 Jun 2008 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".