0

I using django version 3.0.2. I'd like to use postgreSQL as my instance db.

And there are two version postgreSQL in server.

enter image description here

After config setting.py DATABASES parameter, and runserver. It showed error.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'dj_web_console',
        'USER': 'django',
        'PASSWORD': 'django',
        'HOST': 'localhost',
        'PORT': '',
    }
}

psycopg2.OperationalError: FATAL: password authentication failed for user "django"

I'm sure that the username and password are correct.

How to config pg_path in Django as odoo:

enter image description here

In this case, I can use the specific version of pgsql. And run smoothly.

3
  • Django isn't starting Postgres. You should be starting the Postgres server yourself, at which point you can decide what version to start. Commented Sep 2, 2020 at 7:51
  • How and where to set it? I can understand what you say. In my case, I have a "9.6" version of pg with db named "A", the other version is 12 with db named "B", If I set the DATABASE parameter to A (version "9.6"), It can run!! But I can not set it to B. It will cause an error. Commented Sep 3, 2020 at 0:58
  • How are you starting your database server…‽ Commented Sep 3, 2020 at 4:34

1 Answer 1

2

I solve this by indicating the port of the version I installed. In this case, I have a version 9.6 which install in 5432 and the other is 5433. So I just solved this by filling in 5433.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'dj_web_console',
        'USER': 'django',
        'PASSWORD': 'django',
        'HOST': 'localhost',
        'PORT': '5433',
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.