首页 > 解决方案 > 由于权限,无法使用 pg_dump 转储 Django 数据库

问题描述

我想将 PostgreSQL 数据库转储到 SQL 文件。这是pg_dump DB_NAME > dump.sql命令结果:

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

当我想列出关系时:

postgres=# \d
No relations found.

模式列表:

                          List of schemas
  Name  |  Owner   |  Access privileges   |      Description       
--------+----------+----------------------+------------------------
 public | postgres | postgres=UC/postgres+| standard public schema
        |          | =UC/postgres        +| 
        |          | root=U/postgres     +| 
        |          | secretusr=U/postgres | 
(1 row)

数据库列表:

                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges    
-----------+----------+----------+-------------+-------------+------------------------
 db_secret | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres          +
           |          |          |             |             | postgres=CTc/postgres +
           |          |          |             |             | secretusr=CTc/postgres+
           |          |          |             |             | root=CTc/postgres
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres           +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres           +
           |          |          |             |             | postgres=CTc/postgres
(4 rows)

问题出在哪里?

标签: djangopostgresqlubuntu

解决方案


推荐阅读