MySQL 错误 1396 (HY000):“用户”@“本地主机”操作 DROP USER 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20698335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost'
提问by user3086014
I have created a user in mysql. Now i want to delete the user ? How to do that? I am getting this error :
我在mysql中创建了一个用户。现在我想删除用户?怎么做?我收到此错误:
ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost'
I am using this command :
我正在使用这个命令:
DROP USER 'user'@'localhost';
Its an amazon machine.
它是亚马逊机器。
Thanks
谢谢
回答by Tom Mac
It is likely that the user you are trying to drop does not exist. You can confirm (or not) whether this is the case by running:
您尝试删除的用户很可能不存在。您可以通过运行来确认(或否)是否是这种情况:
select user,host
from mysql.user
where user = '<your-user>';
If the user does exist then try running:
如果用户确实存在,则尝试运行:
flush privileges;
drop user 'user'@'localhost';
Another thing to check is to make sure you are logged in as root
user
要检查的另一件事是确保您以root
用户身份登录
If all else fails then you can manually remove the user like this:
如果所有其他方法都失败了,那么您可以像这样手动删除用户:
delete from mysql.user
where user='<your-user>'
and host = 'localhost';
flush privileges;
回答by user3086014
It was because i created the user using command :
这是因为我使用命令创建了用户:
CREATE USER 'user'@'%' IDENTIFIED BY 'passwd';
and i was deleting it using :
我正在使用以下方法删除它:
drop user 'user'@'localhost';
and i should have used this command :
我应该使用这个命令:
drop user 'user'@'%';
回答by Q10Viking
How to solve problem like this:
如何解决这样的问题:
mysql> drop user 'q10'@'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for 'q10'@'localhost'
First:you should check what host of your user,such as:
首先:您应该检查您的用户的主机,例如:
mysql> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | q10 |
| localhost | root |
| localhost | sy |
| localhost | tom |
+-----------+------+
if I drop user 'q10',the command is :
如果我删除用户“q10”,命令是:
mysql> drop user 'q10'@'%';
Query OK, 0 rows affected (0.00 sec)
And if I drop user 'tom',the command as follow:
如果我删除用户“tom”,命令如下:
mysql> drop user 'tom'@'localhost';
Query OK, 0 rows affected (0.00 sec)