我正在尝试在mysql中创建新用户,
create user 'saravanakumar'@'localhost' identified by 'saravanakumar';
它显示错误,
ERROR 1396 (HY000): Operation CREATE USER failed for 'saravanakumar'@'localhost'
我读完之后
ERROR 1396 (HY000): Operation CREATE USER failed for 'jack'@'localhost'
我删除了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)
如何删除表中的所有这些用户以及如何创建单个用户。这个问题的根本原因是什么?专家请帮帮我。
答案 0 :(得分:12)
ERROR 1396 (HY000): Operation CREATE USER failed for 'saravanakumar'@'localhost'
确实表明用户已存在或确实存在。
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.
您正在寻找DROP USER。
DROP USER user [, user] ...
http://dev.mysql.com/doc/refman/5.1/en/drop-user.html
商业秩序将是:
DROP USER 'saravanakumar'@HOSTNAME;
CREATE USER 'saravanakumar'@HOSTNAME [IDENTIFIED BY 'password'];
如果您使用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'];
“user”要求您指定帐户名称
Syntax for account names is 'user_name'@'host_name'
和
An account name consisting only of a user name is equivalent
to 'user_name'@'%'. For example, 'me' is equivalent to 'me'@'%'.
补充阅读:http://dev.mysql.com/doc/refman/5.1/en/account-names.html
请阅读这些错误报告以获得进一步说明
答案 1 :(得分:2)
对我来说,我在大写中设置主机名:
DROP USER' user' @' LOCALHOST'
答案 2 :(得分:0)
select User, Host from mysql.user;
向我说清楚发生了什么。我最终在几台主机下遇到了同一个用户。删除不需要的内容有帮助!