Python psycopg2.errors.InsufficientPrivilege:拒绝关系django_迁移的权限

Python psycopg2.errors.InsufficientPrivilege:拒绝关系django_迁移的权限,python,django,database,postgresql,amazon-ec2,Python,Django,Database,Postgresql,Amazon Ec2,my settings.py for DB的外观: ALLOWED_HOSTS = ['*'] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'fishercoder', 'USER': 'fishercoderuser', 'PASSWORD': 'password', 'HOS

my settings.py for DB的外观:

ALLOWED_HOSTS = ['*']

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'fishercoder',
        'USER': 'fishercoderuser',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}
我通过以下方式创建了一个名为“fishercoder”的新的空数据库:

psql -U postgres
create database fishercoder; 
ALTER USER postgres with password 'badpassword!'; 
CREATE USER fishercoderuser WITH PASSWORD 'password';
ALTER ROLE fishercoderuser SET client_encoding TO 'utf8';
ALTER ROLE fishercoderuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE fishercoderuser SET timezone TO 'PST8PDT';
GRANT ALL PRIVILEGES ON DATABASE fishercoder TO fishercoderuser;

然后,通过运行:
psql-U postgres-fishercoder

然后,我尝试在这个EC2实例上的Django项目上运行
/manage.py makemigrations
,但出现以下错误:

Traceback (most recent call last):
  File "/home/ubuntu/myprojectdir/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.InsufficientPrivilege: permission denied for relation django_migrations
我在上面找到了这三个相关的帖子: ,及

我尝试了他们建议的命令:

postgres=# GRANT ALL ON ALL TABLES IN SCHEMA public to fishercoderuser;
GRANT
postgres=# GRANT ALL ON ALL SEQUENCES IN SCHEMA public to fishercoderuser;
GRANT
postgres=# GRANT ALL ON ALL FUNCTIONS IN SCHEMA public to fishercoderuser;
GRANT
运气不好,然后我重新启动了我的postgresql数据库:
sudo服务postgresql重新启动
当我再次尝试运行迁移时,仍然面临相同的错误

更多调试信息如下:

ubuntu@ip-xxx-xxx-xx-xx:~$ psql -U postgres
Password for user postgres:
psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
Type "help" for help.

postgres=# \dt django_migrations
Did not find any relation named "django_migrations".
postgres=# \d django_migrations
Did not find any relation named "django_migrations".
postgres=#  \dp django_migrations
                            Access privileges
 Schema | Name | Type | Access privileges | Column privileges | Policies
--------+------+------+-------------------+-------------------+----------
(0 rows)

postgres=# SHOW search_path; \dt *.django_migrations
   search_path
-----------------
 "$user", public
(1 row)

Did not find any relation named "*.django_migrations".

postgres=# \dn+ public.
                                     List of schemas
        Name        |  Owner   |  Access privileges   |           Description
--------------------+----------+----------------------+----------------------------------
 information_schema | postgres | postgres=UC/postgres+|
                    |          | =U/postgres          |
 pg_catalog         | postgres | postgres=UC/postgres+| system catalog schema
                    |          | =U/postgres          |
 pg_temp_1          | postgres |                      |
 pg_toast           | postgres |                      | reserved schema for TOAST tables
 pg_toast_temp_1    | postgres |                      |
 public             | postgres | postgres=UC/postgres+| standard public schema
                    |          | =UC/postgres         |
(6 rows)

有什么办法解决这个问题吗?

请尝试使用下面的命令,这对我很有效

GRANT rds_superuser TO username;

你确定你知道django_migrations在哪里以及谁拥有它吗?在psql中\dt django_迁移显示了什么?还有\dp django_迁移?谢谢@AdrianKlaver,我刚才运行了这两个命令并在问题中添加了输出。有趣的是,我还有一个EC2实例,我的另一个Django项目运行得非常好,这两个命令显示的结果完全相同\dt*.django_migrations刚刚添加了这个命令的输出@阿德里安:你能修好吗?我在尝试导入db以使项目在本地运行时遇到相同的问题。还可以在导入数据库转储后立即获取
django.db.utils.ProgrammingError:拒绝表django_迁移的权限。