Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After a PostgreSQL restore, I get "permission denied for relation django_session"

I'm currently running my Django 1.1.1 site with PostgreSQL 8.4.2 both on the live server and locally. When I try to restore one of my backup from the live server on my local box, I get the following error while accessing my site locally(http://localhost:8000):

Exception Type: ProgrammingError at /
Exception Value: permission denied for relation django_session

I also get a similar error while accessing all the contents of one of my models:

$ python manage.py shell
Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from myapp.models import MyModel
>>> MyModel.objects.all()
...
ProgrammingError: permission denied for relation myapp_mymodel

I used pg_dump for backup on the live server and dropping my local db followed by psql dbname < infile for restore. Does anyone know what's wrong?

like image 649
Thierry Lam Avatar asked Feb 20 '10 15:02

Thierry Lam


2 Answers

Do you get the same error when connecting with psql as the same user (the user Django connects as)? Or do you have the same PostgreSQL users on your live site and your local machine? If not, you should dump/reload with the -Ox (or --no-owner) option to skip the ownership commands.

like image 148
copelco Avatar answered Nov 03 '22 07:11

copelco


I try with all you role for user with attribute SUPERUSER. It works.

ALTER ROLE your_role SUPERUSER;
like image 35
Komang Suryadana Avatar answered Nov 03 '22 07:11

Komang Suryadana