错误1396(HY000):“用户名" @“本地主机"的CREATE USER操作失败,由"mypassword"标识; [英] ERROR 1396 (HY000): Operation CREATE USER failed for 'username'@'localhost' IDENTIFIED BY 'mypassword';
问题描述
错误地我从mysql.user
表中删除了我的root用户.
Mistakenly I deleted my root user from my mysql.user
table.
delete from mysql.user where user='username';
要创建相同的root用户,我尝试在查询下面触发
To make same root user, I am trying to fire below query,
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
我收到错误消息
ERROR 1396 (HY000): Operation CREATE USER failed for 'username'@'localhost'
根据此SO答案,我尝试了FLUSH PRIVILEGES;
,但仍然出现相同的错误.
As per this SO answer, I tried FLUSH PRIVILEGES;
, but still I get same error.
有什么想法吗?
我还必须从mysql.db
表中删除相同的内容
I also had to delete the same from mysql.db
table
delete from mysql.db where user='username';
就这样...
推荐答案
如果使用DROP USER
命令删除用户,则该用户将被完全删除.如果以后必须添加具有相同用户名的用户,则可以使用FLUSH PRIVILEGES命令从mysql内存中完全删除特权.
If you use DROP USER
command to remove the user, then the user gets removed completely. If you have to add user with same username later, you can use FLUSH PRIVILEGES command to completely remove privileges from the mysql memory.
DROP USER username@hostname;
在创建同一用户之前,您必须restart mysql
或运行FLUSH PRIVILEGES
,因为特权存在问题.
在基于Linux的系统中重新启动mysql
You have to restart mysql
or run FLUSH PRIVILEGES
before creating the same user because there are issues with privileges.
To restart mysql in linux based systems
sudo service mysql restart
在Windows系统中重新启动
to restart in windows systems
net stop mysql
net start mysql
要在mysql提示符下刷新特权
To flush privilege in mysql prompt
FLUSH PRIVILEGES;
如果知道用户具有哪些特权,则可以选择使用REVOKE
命令
You can alternatively use REVOKE
command if you know which privileges that the user has
REVOKE privillege1, privillege2, ... FROM deleted_user@host
这篇关于错误1396(HY000):“用户名" @“本地主机"的CREATE USER操作失败,由"mypassword"标识;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!