Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

like image 468
boulder_ruby Avatar asked Oct 10 '13 17:10

boulder_ruby


People also ask

How do I fix Postgres permission denied?

Grant privileges to a new user We resolve this permission denied error using the command. GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO new_user; The new_user was then able to read data from the table. Similarly, we can also resolve the permission denied error by setting DEFAULT privileges to the user.

How do I check grant permissions in PostgreSQL?

Another way to do this is to use the information_schema schema and query the table_privileges table as: $ SELECT * FROM information_schema. table_privileges LIMIT 5; The above query will show detailed information about user privileges on databases as well as tables.

How do I connect to a Postgres database?

In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what user name you want to connect as. psql can be told about those parameters via command line options, namely -d, -h, -p, and -U respectively.


1 Answers

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).

like image 186
Zoltán Avatar answered Oct 15 '22 07:10

Zoltán