42501:在Postgresql中查询时,权限不足错误 [英] 42501: INSUFFICIENT PRIVILEGE ERROR while querying in Postgresql

查看:2952
本文介绍了42501:在Postgresql中查询时,权限不足错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在postgresql中查询数据库表,但是每次我运行以下查询时,它都会给我INSUFFICIENT PRIVILEGE错误。此类权限被拒绝错误的原因可能是什么。另外,我在Windows中使用pgadmin工具来连接Linux环境中的数据库。以下是我正在运行的查询

I am trying to query a database table in postgresql, but every time I run the below query it gives me the INSUFFICIENT PRIVILEGE error. What possibly could be the reason for such permission denied error. Also, I am using pgadmin tool in windows to connect the database which is in Linux environment. Below is the query I am running

> > SELECT appid,hash 
>       FROM app
>       WHERE appid=1;

在运行相同查询时出现以下错误

While running the same query I am getting the below Error

ERROR:  permission denied for relation app

********** Error **********

ERROR: permission denied for relation app
SQL state: 42501


推荐答案

运行查询的用户将需要对该表的权限。您可以使用GRANT语句将它们授予该用户。下面是一个向PUBLIC授予权限的示例

The user running the query will need permissions to that table. You can grant them to that user with the GRANT statement. The below is an example that grants to PUBLIC

GRANT SELECT ON tablename TO PUBLIC;

我也看到了SELinux引起的问题以及诸如此处进行提及。我不太确定关闭SELinux的命令,但是您可以使用

Also I have seen SELinux cause isses and places such as here mention it. I am not exactly sure of the command to turn SELinux off but you can see if it is running by using

selinuxenabled && echo enabled || echo disabled

这篇关于42501:在Postgresql中查询时,权限不足错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆