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