在mysql ERROR 1396(HY000)中创建和删除用户时:操作CREATE USER

sar*_*mar 10 mysql

我想在mysql中创建新用户,

    create user 'saravanakumar'@'localhost' identified by 'saravanakumar';
Run Code Online (Sandbox Code Playgroud)

它显示错误,

    ERROR 1396 (HY000): Operation CREATE USER failed for 'saravanakumar'@'localhost'
Run Code Online (Sandbox Code Playgroud)

我读完之后

ERROR 1396(HY000):"jack"@"localhost"的操作CREATE USER失败

我删除了user.But我不能.它显示

    mysql> SELECT User FROM mysql.user;
    +---------------+
    | User          |
    +---------------+
    | root          |
    | saravanakumar |
    | saravanakumar |
    |               |
    | root          |
    | saravanakumar |
    |               |
    | root          |
    +---------------+
    8 rows in set (0.00 sec)

    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)

    mysql> SELECT User FROM mysql.user;
    +---------------+
    | User          |
    +---------------+
    | root          |
    | saravanakumar |
    | saravanakumar |
    |               |
    | root          |
    | saravanakumar |
    |               |
    | root          |
    +---------------+
    8 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

如何删除表中的所有这些用户以及如何创建单个用户.这个问题的根本原因是什么?专家请帮帮我.

Xev*_*ion 12

ERROR 1396 (HY000): Operation CREATE USER failed for 'saravanakumar'@'localhost'
Run Code Online (Sandbox Code Playgroud)

确实表明用户已经存在或确实存在.

FLUSH PRIVILEGES不会删除用户.

Reloads the privileges from the grant tables in the mysql database.

The server caches information in memory as a result of GRANT, CREATE USER, 
CREATE SERVER, and INSTALL PLUGIN statements. This memory is not released 
by the corresponding REVOKE, DROP USER, DROP SERVER, and UNINSTALL PLUGIN 
statements, so for a server that executes many instances of the statements 
that cause caching, there will be an increase in memory use. 
This cached memory can be freed with FLUSH PRIVILEGES.
Run Code Online (Sandbox Code Playgroud)

您正在寻找DROP USER.

DROP USER user [, user] ...
Run Code Online (Sandbox Code Playgroud)

http://dev.mysql.com/doc/refman/5.1/en/drop-user.html


商业秩序将是:

DROP USER 'saravanakumar'@HOSTNAME;
CREATE USER 'saravanakumar'@HOSTNAME [IDENTIFIED BY 'password'];
Run Code Online (Sandbox Code Playgroud)

如果您使用delete(不),则可能需要刷新权限. 请记住:这不一定会撤销此用户可能具有的所有权限(例如表权限),您必须自己执行此操作 - 否则您可能无法重新创建用户.

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'saravanakumar'@HOSTNAME;
DELETE FROM mysql.user WHERE user='saravanakumar';
FLUSH PRIVILEGES;
CREATE USER 'saravanakumar'@HOSTNAME [IDENTIFIED BY 'password'];
Run Code Online (Sandbox Code Playgroud)

"user"要求您指定帐户名称

Syntax for account names is 'user_name'@'host_name'
Run Code Online (Sandbox Code Playgroud)

An account name consisting only of a user name is equivalent 
to 'user_name'@'%'. For example, 'me' is equivalent to 'me'@'%'.
Run Code Online (Sandbox Code Playgroud)

补充阅读:http://dev.mysql.com/doc/refman/5.1/en/account-names.html


请阅读这些错误报告以获得进一步说明

http://bugs.mysql.com/bug.php?id=28331

http://bugs.mysql.com/bug.php?id=62255