MySQL“mysql没有为用户定义这样的授权”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37370004/
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
MySQL "mysql there is no such grant defined for user"
提问by eaglesky
This error happened when I granted all privileges to a new root account I just created.
当我将所有权限授予我刚刚创建的新 root 帐户时,就会发生此错误。
Steps to produce the problem:
产生问题的步骤:
CREATE USER 'root'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SHOW GRANTS for 'root'@'localhost';
After "show grants" I got the error "mysql there is no such grant defined for user 'root' on host 'localhost'". There were no errors after executing the first three commands. The new user was created successfully.
在“显示授权”之后,我收到错误“mysql 没有为主机 'localhost' 上的用户 'root' 定义这样的授权”。执行前三个命令后没有错误。新用户创建成功。
How do I solve this problem?
我该如何解决这个问题?
More info: I'm running MySQL 5.7 on my MacOS laptop(OSX 10.10.5).
更多信息:我在 MacOS 笔记本电脑(OSX 10.10.5)上运行 MySQL 5.7。
回答by Rahul
There is nothing wrong with your posted code but as guess try with wildcard symbol %
like
您发布的代码没有任何问题,但猜测尝试使用通配符,%
例如
SHOW GRANTS for 'root'@'%';
(OR)
(或者)
As an alternative, login with your created user 'root'@'localhost'
and just use SHOW GRANTS
. See Documentation
或者,使用您创建的用户登录'root'@'localhost'
并使用SHOW GRANTS
. 查看文档
回答by Saqib Rokadia
I don't think mysql allows you to create another root account. So the create causes an error.
我认为 mysql 不允许您创建另一个 root 帐户。所以创建会导致错误。
CREATE USER 'root'@'localhost';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'
You should check for the existing root account in the user table and you'll find the wildcard to be '%' which should mean you do not need to create a localhost root user.
您应该检查用户表中现有的 root 帐户,您会发现通配符为“%”,这意味着您不需要创建 localhost root 用户。
select * from user where user = 'root';
Asking to show grants on root localhost should work, and does work for me.
要求在 root localhost 上显示授权应该有效,并且对我有用。
show grants for 'root'@'localhost';
回答by Sanjit Majee
Step-1:sudo mysql -u root -p
步骤 1:sudo mysql -u root -p
Step-2:REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user name'@'localhost';
第 2 步:撤销所有权限,从 'user name'@'localhost' 授予 OPTION;
Ex.- REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'admin'@'localhost';
例如-撤销所有特权,从'admin'@'localhost'授予选项;
Step-3:FLUSH PRIVILEGES;
第 3 步:刷新特权;
I think it will work.
我认为它会起作用。