问题描述
我查看了许多类似的问题,因此我要证明我已经检查了基础知识.当然,这并不意味着我没有遗漏一些完全显而易见的事情.:-)
I've looked at a number of similar questions and so I'm demonstrating that I've checked the basics. Though of course, that doesn't mean I haven't missed something totally obvious. :-)
我的问题是:为什么我拒绝访问有权执行我正在尝试执行的操作以及我已经输入密码并获得访问权限的用户?(为了完整起见,我尝试输入错误的密码只是为了确保 MySQL 客户端会在程序启动时拒绝我访问.)
My question is: why am I denied access on a user with the privileges to do what I'm trying to do and where I have already typed the password and been granted access? (For the sake of completeness, I tried typing the wrong password just to make sure that MySQL client would deny me access at program start.)
背景:
通过ssh登录到运行MySQL服务器的机器的shell,我以root身份登录:
Logged in to the shell of the machine running the MySQL server via ssh, I log in as root:
棒极了.我对类似问题的回答表明我应该确保权限与授权表中的内容保持一致
Awesome. My reading of the answers to similar questions suggests that I should make sure the the privileges are current with what is in the grant tables
接下来确保我是我认为的我:
Next make sure I am who I think I am:
...并且真的真的确保:
到目前为止一切顺利.现在我有什么特权?
So far so good. Now what privileges do I have?
现在这有点难以阅读,所以让我们试试这种方式(您还将看到有一个非本地主机root"用户):
Now that's a little hard to read, so lets try this way (you will also get to see that there is a non-localhost 'root' user):
太棒了!MySQL 认为我是 root@localhost 并且 root@localhost 拥有所有这些权限.这意味着我应该能够做我想做的事,对吗?
Awesome! MySQL thinks that I am root@localhost and root@localhost has all those privileges. That means I ought to be able to do what I want, right?
我怎么会把这么基本的东西搞砸?
How could I have screwed up something this basic?
旁注:对于那些想建议我没有一个名为 root 的用户拥有所有权限的人来说,这很好,一旦我可以给另一个用户一些权限,我就会考虑这样做.
Side note: for anyone who wants to suggest that I not have a user named root with all privileges, that's great and something I'll consider doing once I can give another user some privileges.
谢谢!
推荐答案
注意
没有说所有特权",但必须说明 root@localhost 有什么.
did not say 'ALL PRIVILEGES' but had to spell out what root@localhost has.
GRANT ALL PRIVILEGES 会失败,因为用户不能授予他/她没有的东西,并且服务器似乎认为有些东西不在这里......
GRANT ALL PRIVILEGES will fail, because a user can not grant what he/she does not have, and the server seem to think something is not here ...
现在还缺少什么?
在我的系统上,我得到了这个:
On my system, I get this:
5.5 中也有新表,比如 mysql.proxies_user:确保你有它们.
There are also new tables in 5.5, such as mysql.proxies_user: make sure you have them.
当安装一个全新的 mysql 服务器实例时,安装脚本将创建所有具有正确结构的 mysql.* 表.
When installing a brand new mysql server instance, the install script will create all the mysql.* tables with the proper structure.
从旧版本升级时,请确保使用正确的升级过程(mysql_upgrade),这将添加缺少的表/列.
When upgrading from an old version, make sure the proper upgrade procedure (mysql_upgrade) is used, which will add the missing tables / columns.
这只是一个猜测,但似乎没有为此实例执行 mysql_upgrade,导致了所见的行为.
It is only a guess, but it seems mysql_upgrade was not done for this instance, causing the behavior seen.
这篇关于尝试授予权限时,用户 'root'@'localhost' 的访问被拒绝.如何授予权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!