getting permission denied for relation in potgresql - postgresql

I connected to my db using this command
psql -U bm_clients -d Bayne_DB
and then I tried to run this command
Bayne_DB=> GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA abcd TO bm_clients;
For which I received this error
ERROR: permission denied for relation provider_seq
How to resolve this?

Make sure that "Bayne_DB" owns all affected objects.

Related

Cannot import database postgresql

I'm just starting with postgresql and I'm trying to import a database using Postbird but I get that error:
I've installed postgresql-client as suggested but still getting the error.
So I tried using the CLI instead.
I successfully created my database baseball:
postgres=# CREATE DATABASE baseball;
and I granted all privileges to my user:
postgres=# GRANT ALL PRIVILEGES ON DATABASE baseball TO postgres;
But then when I run postgres#dev-L140PU:~$ psql -U postgres -d baseball < /home/dev/Document/codecademy/TheBestOfBaseballAwards/baseball_database.sql, I get this error:
-bash: /home/dev/Document/codecademy/TheBestOfBaseballAwards/baseball_database.sql: Permission denied.
How can I solve this please?

AWS RDS Postgres error while taking the dump

When I try to take PostgresDump (AWS RDS) the following error I am getting:
ERROR: permission denied for relation dms_stats_detailed
pg_dump: error: query was: LOCK TABLE table_name IN ACCESS SHARE MODE
I am having admin permission though (with Master User).
You need to run pg_dump with a database user (the -U option) that has permission to read the tables you are dumping.

postgres: error: db doesnt exist ( psql create user case senstivity issue)

I have this database triviaDB that i am connecting to from a flask-sqlalchemy 'postgresql://devuser:devpass#localhost:5432/triviaDB'however it's giving me a programing error psycopg2: auth not allowed.
so i use the following commands in psql to try and give devuser authorization on this database but here is the problem
when i run GRANT ALL PRIVILEGES ON DATABASE triviaDB to devuser; iget this error:
ERROR: database "triviadb" does not exist
when i quote the db name GRANT ALL PRIVILEGES ON DATABASE 'triviaDB' TO devuser; i get this :
ERROR: syntax error at or near "'triviaDB'"
If the DB name was created with upper cases, you need to use double quotes:
GRANT ALL PRIVILEGES ON DATABASE "triviaDB" to devuser;

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

Becoming a superuser postgresql

How do i make myself a superuser on postgresql?
I keep trying to create a database and I keep getting the following errors:
createdb: database creation failed: ERROR: permission denied to create database
I'm guessing this is because i'm not a superuser but i don't know what's wrong.
Here's what i did:
> sudo su postgres
> postgres#precise64:/xxx/xxx/projectfile$createuser -P
> Enter name of role to add: vagrantUser
> Enter password:
> Enter it again:
> Shall the new role be a superuser? (y/n) y
> postgres#precise64:/vagrant/django_projects/mblog$ psql -U vagrantUser template1
> psql: FATAL: Peer authentication failed for user "vagrantUser"
> postgres#precise64:/vagrant/django_projects/mblog$ exit
> (venv)vagrant#precise64:/vagrant/project$:psql template1
> template1 =# \q
> (venv)vagrant#precise64:/vagrant/project$:createdb mydb
I get the following error:
createdb: database creation failed: ERROR: permission denied to create database
Pleae help
Long story short - you don't want vagrant to be superuser. instead, make the vagrant database from postgres account, and make it's owner (i.e. the database) vagrant user.
The createuser script takes a "--createdb" option to allow the new user to create databases (see http://www.postgresql.org/docs/8.1/static/app-createuser.html).
You did not specify this, so "vagrantUser" cannot create new databases.
Having said that, #depesz makes a good point - it's best practice to have a single superuser/root database account and use that to create/maintain databases, create separate accounts for databases and grant appropriate permissions to those accounts; but I was totally focused on the problem =)