我在mysql中创建了一个用户,现在我想删除这个用户。该怎么做?我收到了以下错误信息:
ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost'
我正在使用这个命令:
DROP USER 'user'@'localhost';
这是一台亚马逊机器。
谢谢。
我在mysql中创建了一个用户,现在我想删除这个用户。该怎么做?我收到了以下错误信息:
ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost'
我正在使用这个命令:
DROP USER 'user'@'localhost';
这是一台亚马逊机器。
谢谢。
这是因为我使用命令创建了该用户:
CREATE USER 'user'@'%' IDENTIFIED BY 'passwd';
然后我使用以下方式删除它:
drop user 'user'@'localhost';
我应该使用这个命令:
drop user 'user'@'%';
drop user 'user'@'%';
(在刷新权限之前和之后),我仍然遇到了 HY000 错误。这个答案可以通过指出第二组单引号可能被限定为不同的值来改进。 - Alexisselect user,host from mysql.user
命令,以查看 @
后面属于哪个主机。 - scai你要删除的用户可能不存在。您可以通过运行以下命令来确认(或不确认)这一点:
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>';
如果用户存在,则尝试运行:
flush privileges;
drop user 'user'@'localhost';
另一个需要检查的事情是确保你已经以root
用户身份登录。
如果其他方法都失败了,那么你可以手动像这样删除用户:
delete from mysql.user
where user='<your-user>'
and host = 'localhost';
flush privileges;
如何解决这类问题:
mysql> drop user 'q10'@'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for 'q10'@'localhost'
首先:您应该检查您的用户所使用的主机,例如:
mysql> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | q10 |
| localhost | root |
| localhost | sy |
| localhost | tom |
+-----------+------+
如果我要删除用户 'q10',命令是:
mysql> drop user 'q10'@'%';
Query OK, 0 rows affected (0.00 sec)
如果我要删除用户'tom',则命令如下:
mysql> drop user 'tom'@'localhost';
Query OK, 0 rows affected (0.00 sec)
从mysql.user表中删除用户'user_name'和主机名为'localhost'的记录;
刷新权限;
对我有用...
DROP USER user@localhost;
在MySQL 8中应该可以这样工作。我也遇到了这个问题。