Bug #80636 CREATE USER IF NOT EXISTS throws error instead of warning
Submitted: 7 Mar 2016 9:42 Modified: 19 Jan 2022 7:29
Reporter: Lars Tangvald Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S3 (Non-critical)
Version:5.7.11 OS:Any
Assigned to: Harin Vadodaria CPU Architecture:Any

[7 Mar 2016 9:42] Lars Tangvald
Description:
Running CREATE USER IF NOT EXISTS should produce a warning if the user already exists, but if the command also specifies a password it will instead produce a generic error message.

Expected behavior:
mysql> create user if not exists 'user'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> create user if not exists 'user'@'localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+-----------------------------------------+
| Level | Code | Message                                 |
+-------+------+-----------------------------------------+
| Note  | 3163 | User 'user'@'localhost' already exists. |
+-------+------+-----------------------------------------+
1 row in set (0.00 sec)

----
Behavior with password specified:

mysql> create user if not exists 'user'@'localhost' identified by 'pass';
ERROR 1396 (HY000): Operation CREATE USER failed for 'user'@'localhost'

How to repeat:
Log into the server and run:
 create user if not exists 'user'@'localhost' identified by 'pass';

twice
[19 Jan 2022 7:29] Omar Sharieff
This bug is a duplicate of Bug#78374 and is fixed by the patch for Bug#78374