Navicat 1142 SELECT command denied to user ‘sx’@’xxx’ for table ‘user’ – G

Navicat 1142 SELECT command denied to user ‘sx’@’xxx’ for table ‘user’ – GNavicat 1142 SELECT command denied to user 'sx'@'xxx' for table &amp

Navicat 1142 SELECT command denied to user 'sx'@'xxx' for table 'user' - G

Navicat 1142 SELECT command denied to user “sx”@”xxx” for table “user”

 

使用Navicat使用sx用户连接数据库时或者连接为用户sx开放的数据库travel_agency时,Navicat窗口弹出上述问题

![](D:思创斯聊编程随笔pictures avicat 1142.jpg)

 

具体原因

具体原因就是该用户(sx)无法读取user表(但注意,应该是mysql版本改动表名发生了变化,实际上无法读取的是mysql.user表)

 

处理方式:(不用重启数据库服务)

  • 首先检验此时的授权情况

    mysql> show grants for sx;
    +-------------------------------------------------------------------------+
    | Grants for sx@%                                                         |
    +-------------------------------------------------------------------------+
    | GRANT USAGE ON *.* TO "sx"@"%"                                          |
    | GRANT ALL PRIVILEGES ON `travel_agency`.* TO "sx"@"%" WITH GRANT OPTION |
    +-------------------------------------------------------------------------+
    2 rows in set (0.00 sec)
    

    代码100分

  • 通过root方式连接数据库,然后通过Navicat让sx用户获得user数据库以及mysql.user表的select权限(仅授权select)

    Navicat 1142 SELECT command denied to user 'sx'@'xxx' for table 'user' - G![navicat 1142_2](D:思创斯聊编程随笔pictures avicat 1142_2.png)

  • 再次查询授权情况

    代码100分mysql> show grants for sx;
    +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Grants for sx@%                                                                                                                                                                                                                                |
    +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | GRANT USAGE ON *.* TO "sx"@"%"                                                                                                                                                                                                                 |
    | GRANT SELECT ON `user`.* TO "sx"@"%"                                                                                                                                                                                                           |
    | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `travel_agency`.* TO "sx"@"%" WITH GRANT OPTION |
    | GRANT SELECT ON `mysql`.`user` TO "sx"@"%"                                                                                                                                                                                                     |
    +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    4 rows in set (0.00 sec)
    

    当然,也可以在命令行中手动赋权,如GRANT SELECT ON user.* TO "sx"@"%"

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/7317.html

(0)
上一篇 2023-03-22
下一篇 2023-03-22

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注