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.
它的一个amazon machine。
Thanks
谢谢
3 个解决方案
#1
29
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
另外要检查的是确保您作为根用户登录。
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;
#2
24
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'@'%';
#3
0
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 :
如果我删除user 'q10',命令是:
mysql> drop user 'q10'@'%';
Query OK, 0 rows affected (0.00 sec)
And if I drop user 'tom',the command as follow:
如果我删除user 'tom',命令如下:
mysql> drop user 'tom'@'localhost';
Query OK, 0 rows affected (0.00 sec)
#1
29
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
另外要检查的是确保您作为根用户登录。
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;
#2
24
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'@'%';
#3
0
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 :
如果我删除user 'q10',命令是:
mysql> drop user 'q10'@'%';
Query OK, 0 rows affected (0.00 sec)
And if I drop user 'tom',the command as follow:
如果我删除user 'tom',命令如下:
mysql> drop user 'tom'@'localhost';
Query OK, 0 rows affected (0.00 sec)