postgresql psql:数据库“dbname”的权限被拒绝(“用户没有连接权限。”)/“无法识别的角色选项'connect'”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19302398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:08:54  来源:igfitidea点击:

psql: permission denied for database "dbname" ("User does not have CONNECT privilege.") / "unrecognized role option 'connect'"

postgresqlloginconnectrolepsql

提问by boulder_ruby

when I try to login to my database with psql, doing this:

当我尝试使用 psql 登录到我的数据库时,执行以下操作:

psql dbname --username=qgis --password
>>(prompts for password, entered password)
psql: FATAL:  permission denied for database "gisdatabase"
DETAIL:  User does not have CONNECT privilege.

I've searched around on Google for information on this simple issue but haven't found anyone directly talking about this.

我在谷歌上搜索了关于这个简单问题的信息,但没有找到任何人直接谈论这个。

I've tried doing this:

我试过这样做:

psql dbname
>>ALTER ROLE qgis WITH CONNECT;

But got this error:

但是得到了这个错误:

ERROR:  unrecognized role option "connect"

So once again, here I am, asking yet another question on stackoverflow. Thanks for your time folks

所以再次,我在这里,问另一个关于 stackoverflow 的问题。感谢您的时间

采纳答案by Zoltán

You need to grant a privilege. Try this:

您需要授予特权。试试这个:

psql dbname
>> GRANT CONNECT ON DATABASE dbname TO qgis;

I assume you will also need further privileges. PostgreSQL has one of the best documentation pages of all the DBMSs: http://www.postgresql.org/docs/9.0/static/sql-grant.html(You can choose the postgres version you're using at the top of the page).

我想你还需要更多的特权。PostgreSQL 拥有所有 DBMS 中最好的文档页面之一:http: //www.postgresql.org/docs/9.0/static/sql-grant.html(您可以在顶部选择您正在使用的 postgres 版本页)。