小编典典

mysql忘记了谁登录:命令被拒绝给用户“ @'%'

mysql

正在运行show grants;表示我以具有数据库所有特权的用户身份登录。

运行会show table status;导致错误。并且错误不显示我作为登录用户名!

就好像对于此命令,mysql忘记了我是谁。其他选择语句也可以正常工作。谁能解释一下?怎么修?谢谢。

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.13-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show grants;
+---------------------------------------------------------------------------------------------------------------------+
| Grants for php@localhost                                                                                            |
+---------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'php'@'localhost' IDENTIFIED BY PASSWORD '*8F5FF90079BC601F8EA7C148475658E65A0C029D' |
| GRANT ALL PRIVILEGES ON `sunflower_work`.* TO 'php'@'localhost'                                                     |
| GRANT ALL PRIVILEGES ON `news_demo`.* TO 'php'@'localhost'                                                          |
| GRANT ALL PRIVILEGES ON `news_base`.* TO 'php'@'localhost'                                                          |
+---------------------------------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> show table status from sunflower_work;
ERROR 1143 (42000): SELECT command denied to user ''@'%' for column 'uid' in table 'users'
mysql>

更新…根据Tomalak的建议,我删除了该用户,并使用更充分的特权和密码重新创建了该用户。问题仍然存在。现在看起来像这样:

mysql> show grants;
+--------------------------------------------------+
| Grants for php@localhost                         |
+--------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'php'@'localhost' |
+--------------------------------------------------+
1 row in set (0.00 sec)

mysql> show table status;
ERROR 1143 (42000): SELECT command denied to user ''@'%' for column 'uid' in table 'users'
mysql>

阅读 227

收藏
2020-05-17

共1个答案

小编典典

问题可能是您的数据库中有VIEWS。视图可能是使用特定权限创建的。

您可以从错误消息中看出,它抱怨的用户与您登录的用户 不同 。这是因为对于视图,您可以指定如何确定视图必须具有的查看数据权限。

当您进入数据库时​​,尝试输入:

SHOW FULL TABLES IN sunflower_work WHERE TABLE_TYPE NOT LIKE '%table%';

然后,您可能希望研究那里特定视图的权利。

2020-05-17