Bug #51681 mutli user creation with one command
Submitted: 3 Mar 2010 9:07 Modified: 3 Mar 2010 10:11
Reporter: kali natham Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.1.43 OS:Any (mutli user creation)
Assigned to: CPU Architecture:Any
Tags: addtional, bug, correct, created, creation, fix, improper, kalinatham, more, multi, multiuser, not proper, one command, proper, report, syntax, syntax wrong, user

[3 Mar 2010 9:07] kali natham
Description:
Hi,
while creating multiple user with one command:Issues find:
--> There is no syntax error if its not syntactically correct
--> Treating more user 
--> Treating improper user

Below are the example:

mysql> select version();
+----------------------+
| version()            |
+----------------------+
| 5.1.43-community-log |
+----------------------+
1 row in set (0.05 sec)

How to repeat:
mysql> use mysql;
Database changed

mysql> select user,host ,password from user where user like 'test%';
Empty set (0.00 sec)

mysql> grant all on *.* to test1@localhost,test2@localhost identified by 'test1','test2';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host ,password from user where user like 'test%';
+-------+-----------+-------------------------------------------+
| user  | host      | password                                  |
+-------+-----------+-------------------------------------------+
| test2 | %         |                                           |
| test1 | localhost |                                           |
| test2 | localhost | *06C0BF5B64ECE2F648B5F048A71903906BA08E5C |
+-------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)

Suggested fix:
correct syntax is:
grant all on *.* to test1@localhost identified by 'test1',test2@localhost identified by 'test1';

so syntax verification could resolve the issue.
[3 Mar 2010 9:12] kali natham
.
[3 Mar 2010 9:13] kali natham
.
[3 Mar 2010 9:38] Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

According to http://dev.mysql.com/doc/refman/5.1/en/grant.html both syntax formats are correct: there is no requirement to specify password for a user.
[3 Mar 2010 9:54] kali natham
This is not about syntax,its improper user creation by below query:

mysql> grant all on *.* to test1@localhost,test2@localhost identified by 'test1','test2';
Its creating three users:
1) test1@localhost with no password 
2) test2@% which it should not create 
3) test2@localhost which is fine by executing above query.

Results of above query and below query are not same.

grant all on *.* to test1@localhost identified by 'test1',test2@localhost identified by
'test1';
[3 Mar 2010 10:11] kali natham
You are right :)
I understood the below SQL query,

grant all on *.* to test1@localhost,test2@localhost identified by 'test1','test2';

its actually treated test1@localhost as 1st user creation
test2@localhost identified by test1 as 2nd user
and
test2 as test2@% as 3 rd user.

Thanks
[3 Mar 2010 10:12] Sveta Smirnova
Thank you for the feedback.

> mysql> grant all on *.* to test1@localhost,test2@localhost identified by
'test1','test2';
...
> 2) test2@% which it should not create 

This is still not a bug. See part about default hostname at http://dev.mysql.com/doc/refman/5.0/en/grant.html for details.