I just tried to tướng add a new user to tướng MySQL using
CREATE USER 'name'@'%' IDENTIFIED BY '...'
However, it fails with the following error:
ERROR 1396 (HY000): Operation CREATE USER failed for 'name'@'%'
Adding the user just for localhost works fine:
CREATE USER 'name'@'localhost' IDENTIFIED BY '...'
I have no clue what could be the problem. I'd be grateful for any ideas.
(I'm using mysql Ver 14.14 Distrib 5.1.66
.)
asked Feb 18, 2013 at 13:17
PetrPetr
5372 gold badges5 silver badges11 bronze badges
1
According to tướng the docs if you ommit the @'hostname' (that is CREATE USER 'name') MySQL will interpret it as it had a @'%'. The error message you provided suggests that there is already a user 'name'@'%' in the system:
mysql> CREATE USER 'name'@'%' IDENTIFIED BY 'test';
Query OK, 0 rows affected (0.04 sec)
mysql> CREATE USER 'name'@'%' IDENTIFIED BY 'test';
ERROR 1396 (HY000): Operation CREATE USER failed for 'name'@'%'
mysql> CREATE USER 'name' IDENTIFIED BY 'test';
ERROR 1396 (HY000): Operation CREATE USER failed for 'name'@'%'
If you delete the user and still get the message, try running FLUSH PRIVILEGES.
Also see this SO question for additional info.
answered Feb 18, 2013 at 13:27
redguyredguy
1,0069 silver badges14 bronze badges
I was facing this same error while using mysql:5.7 docker image. Main mistake was trying to tướng create root
user which exists by mặc định.
More information: https://github.com/docker-library/mysql/issues/129
As given in the above liên kết, solution was to tướng NOT mix MYSQL_USER
and MYSQL_PASSWORD
in the environment variables while starting the docker image.
answered May 27, 2018 at 5:31
1