用户"root" @"localhost"的访问被拒绝(使用密码:是)-没有权限?

问题描述:

我不断收到此错误.

我正在使用mySQL Workbench,从中发现,root的架构特权为null.根本没有特权.

I am using mySQL Workbench and from what I am finding is that root's schema privileges are null. There are no privileges at all.

我在使用服务器的平台上遇到了麻烦,这是一个突然的问题.

I am having troubles across platforms that my server is used for and this has been all of a sudden issue.

root@127.0.0.1 显然具有很多访问权限,但我已经以此身份登录,但无论如何它只是分配给localhost-localhost没有特权.

root@127.0.0.1 apparently has a lot of access but I am logged in as that, but it just assigns to localhost anyways - localhost has no privileges.

我已经做了一些事情,例如FLUSH HOSTSFLUSH PRIVILEGES等 但是从那儿或互联网上都找不到成功.

I have done a few things like FLUSH HOSTS, FLUSH PRIVILEGES, etc but have found no success from that or the internet.

如何重新获得对它的访问权限?我发现这很令人沮丧,因为当我环顾四周时,人们希望您拥有访问权限",但是我没有访问权限,因此我无法进入命令行或其他任何内容,并且GRANT自己也没有任何内容.

How can I get root its access back? I find this frustrating because when I look around people expect you to "have access" but I don't have access so I can't go into command line or anything and GRANT myself anything.

运行SHOW GRANTS FOR root时,这是我得到的回报:

When running SHOW GRANTS FOR root this is what I get in return:

错误代码:1141.没有为用户"root"定义这样的授予 主机%"

Error Code: 1141. There is no such grant defined for user 'root' on host '%'

使用

Use the instructions for resetting the root password - but instead of resetting the root password, we'll going to forcefully INSERT a record into the mysql.user table

在init文件中,改用它

In the init file, use this instead

INSERT INTO mysql.user (Host, User, Password) VALUES ('%', 'root', password('YOURPASSWORD'));
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;