PostgreSQL:致命:用户“ douglas”的密码验证失败。 [英] postgresql: FATAL: password authentication failed for user "douglas"

查看:100
本文介绍了PostgreSQL:致命:用户“ douglas”的密码验证失败。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据库从sqlite迁移到postgresql ...所以我键入了以下内容:

I am trying to migrate a DB from sqlite to postgresql...so I typed:

sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';

,输出返回 ALTER ROLE

,但是当我键入 python manage.py migration 时,我总是收到相同的错误:

but when I type python manage.py migrate I receive always the same error:


django.db.utils.OperationalError:致命:用户 douglas的密码身份验证
失败

django.db.utils.OperationalError: FATAL: password authentication failed for user "douglas"

这是我的settings.py的数据库部分。

This is the database sections of my settings.py.

# Old, using mysqlite
"""
DATABASES = {
    #'default': {
    #    'ENGINE': 'django.db.backends.sqlite3',
    #    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    #}
    'default': dj_database_url.config(default='postgres://localhost:5432/postgres_db_name'),
}
"""

# New, using postgres
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'douglas_db',
        'USER': 'douglas',
        'PASSWORD': 'vamointer',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

注意:当我运行 使用密码更改用户postgres 时,我输入了settings.py中定义的相同密码。

Note: When I run the 'ALTER USER postgres WITH PASSWORD' I put in the same password defined in the settings.py.

推荐答案

您正在运行的SQL与您尝试使用的用户不匹配。

The SQL you are running does not match the user you are attempting to use.

您如果不存在,将需要创建用户

You will need to create the user if it does not exist:

CREATE USER douglas WITH PASSWORD 'vamointer';

或者,如果确实存在,则更改该用户的密码

or if it does exist, change that user's password instead.

ALTER USER douglas WITH PASSWORD 'vamointer';

完成后,您应该会获得更多的运气。您可能还需要将权限分配给该用户

Once you have done that you should have more luck. You may need to assign permissions to that user as well.

这篇关于PostgreSQL:致命:用户“ douglas”的密码验证失败。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆