Database Error Permission Denied For Relation Django_session
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site error permission denied for relation sql state 42501 About Us Learn more about Stack Overflow the company Business Learn more about error permission denied for relation spatial_ref_sys hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join error permission denied for relation users the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Django: permission denied when trying error permission denied for relation postgresql to access database after restore (migration) up vote 20 down vote favorite 13 I have a django 1.4 app with a populated postgres 9.1 database in development server locally. After successful deployment, I wanted to move the data from local to online database, so I used: pg_dump -f dump.sql -Ox database and then restored on the server with: psql -1 -f dump.sql database Now trying
Error Permission Denied For Relation Postgres
to login online to the website admin throws a "permission denied for relation django_session" exception. I've tried to dump the data with/without -Ox switch and all its combinations but without success. I am also dropping the database and recreating it from scratch on the server with the correct owner as set in settings.py. If I run a normal syndb without a restore then everything works well. Am I missing something here? django postgresql share|improve this question edited Sep 2 '12 at 14:05 asked Sep 2 '12 at 2:46 Rabih Kodeih 5,24062944 add a comment| 2 Answers 2 active oldest votes up vote 59 down vote accepted It turns out that you should grant explicit ownership of all objects in the database to the owner after restore. The owner is not a superuser. It's not enough to only set the owner at database creation time. The final solution for migration goes like this: on the client: pg_dump -f dump.sql -Ox database on the server: su postgres dropdb database createdb database -O user psql database -f dump.sql and then to set the privileges: psql database -c "GRANT ALL ON ALL TABLES IN SCHEMA public to user;" psq
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more
Error Permission Denied For Relation Schema_migrations
about Stack Overflow the company Business Learn more about hiring developers or posting ads programmingerror: permission denied for relation django_migrations with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow django.db.utils.programmingerror: must be owner of relation is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Permission denied for relation up vote 94 down vote favorite 26 I tried http://stackoverflow.com/questions/12233046/django-permission-denied-when-trying-to-access-database-after-restore-migratio to run simple sql command: select * from site_adzone; and I got this error ERROR: permission denied for relation site_adzone What could be the problem here? I tried also to do select for other tables and got same issue. I also tried to do this: GRANT ALL PRIVILEGES ON DATABASE jerry to tom; but I got this response from console WARNING: no privileges were granted for "jerry" Do you http://stackoverflow.com/questions/15520361/permission-denied-for-relation have some idea what can be wrong? postgresql privileges postgresql-9.2 grant share|improve this question edited Mar 22 '13 at 3:56 Erwin Brandstetter 217k29353463 asked Mar 20 '13 at 10:00 user2186086 5871510 I am not sure how to update permissions so I can read/write in DB –user2186086 Mar 20 '13 at 10:23 1 You need to grant the necessary privileges: postgresql.org/docs/current/static/ddl-priv.html and postgresql.org/docs/current/static/sql-grant.html –a_horse_with_no_name Mar 20 '13 at 10:32 2 Welcome to SO! For this question, you may get more help over at dba.stackexchange.com, though you may find just as many snide comments :) –Jared Beck Mar 28 '13 at 4:09 5 Excuse me. This is the second very programming-related postgresql question I've seen closed as off-topic tonight! The last one had 67,000 views, this one 30,000 views. We should have a popularity clause: Any non-subjective question with > 15,000 views = on topic. –Theodore R. Smith Dec 12 '14 at 5:51 1 This question is not off topic! It is, however, a duplication of stackoverflow.com/questions/13497352/… –wheaties Feb 17 '15 at 20:05 add a comment| 2 Answers 2 active oldest votes up vote 121 down vote accepted GRANT on the database is not what you need. Grant on the tables directly. G
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site http://dba.stackexchange.com/questions/29579/postgresql-permission-denied-for-relation About Us Learn more about Stack Overflow the company Business Learn more about hiring http://python.6.x6.nabble.com/confusion-about-choosing-the-database-user-name-Postgresql-psycopg2-td4343953.html developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's permission denied how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top PostgreSQL: permission denied for relation up vote 11 down vote favorite I'm a bit confused about setting permissions in PostgreSQL. I have these roles: List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- admin | Superuser, Create role, Create DB, Replication | permission denied for {} meltemi | Create role, Create DB | {rails} rails | Create DB, Cannot login | {} myapp | | {rails} and databases: List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ---------------------+--------+----------+-------------+-------------+------------------- myapp_production | rails | UTF8 | en_US.UTF-8 | en_US.UTF-8 | ... user myapp has no problem querying the myapp_production database adding & deleting records. I'd like for meltemi to also be able to query the same database. So, I created a role rails which owns the database and made both meltemi and myapp members of rails. But I still get permission denied for relation errors. Meltemi can view the schema but can't query the DB. I just noticed (with \dt command) that myapp is the owner of the tables: List of relations Schema | Name | Type | Owner --------+-------------------+-------+------- public | events | table | myapp public | schema_migrations | table | myapp ... public | users | table | myapp ... The tables were created via an ORM (Rails' ActiveRecord migrations). I know authorization is very different in PostgreSQL (as opposed to MySQL & others I've used). How should I be setting up my database so
♦ Locked 2 messages Steve W.-2 Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ confusion about choosing the database user name (Postgresql/psycopg2) I'm a little confused about the choice of the database user to specify in the settings.py configuration file. On the one hand, if I set the user to be 'www-data' (the Apache2 user), I can serve pages to the public just fine, but cannot use the admin site. DatabaseError at /admin/ permission denied for relation django_session Which of course is desirable, because user 'www-data' should have read- only access to the tables ------ Conversely, if I set the user to be a real user (ie "myself") then I can utilize the admin site but cannot serve pages to the public. File "/usr/lib/python2.7/dist-packages/django/db/backends/ postgresql_psycopg2/base.py", line 140, in _cursor self.connection = Database.connect(**conn_params) OperationalError: FATAL: Peer authentication failed for user "myself" ----- What am I failing to do or to understand? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. Anssi Kääriäinen-2 Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: confusion about choosing the database user name (Postgresql/psycopg2) You should not use www-data as your user. There is little reason for allowing any access to the database for www-data user. The user in settings.py refers to PostgreSQL user. You should set up a dedicated postgresql user, and a password for that user. Use those in your settings.py. The most likely reason for the error you got is that you have a line like this in your pg_hba.conf (the file is located under /etc/ postgresql/ when using Ubuntu