permission denied for relation django_migrations

Rajat Gupta picture Rajat Gupta · Nov 23, 2015 · Viewed 8.1k times · Source

I am using Django CMS, I want to take backup of my database. But when I am firing the query to take my back of database:

pg_dump -U postgres -h 127.0.0.1 -p 5432 db_name > db_name_backup.sql

After firing the query I am getting the following error:

pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation django_migrations

pg_dump: [archiver (db)] query was: LOCK TABLE public.django_migrations IN ACCESS SHARE MODE

Can anyone help me on this?

Answer

markwalker_ picture markwalker_ · Nov 28, 2015

Sounds like it's down to permissions, so make sure you at least have USAGE for relevant schema and the SELECT privilege for the table.

Check out this answer for much greater detail.