How to indicate to a specific version of database? [Django] [PostgreSQL]

I’m using Django version 3.0.2.
I’d like to use PostgreSQL as my instance DB.

And there are two version PostgreSQL in the server.

image

I can connect to any DB in 9.6 version of PostgreSQL and run server smoothly.
But when I connect to 12 version of pg, it will get an error.

django.db.utils.OperationalError: FATAL: password authentication failed for user "django"
I’m sure the name, user and password are correct.

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

How can I indicate the specific version of DB?

Generally speaking, your different versions of PostgreSQL run on different ports. When you have multiple versions installed, the first will be running on port 5432 by default, and then the numbers go up from there. (Your second-installed version will launch on 5433, and so on.) So what you want to do is find out which port your version of PostgreSQL is running on.
(Note, that’s assuming you’re using a TCP socket for connection and not a Unix socket - but the idea is the same. PostgreSQL will open up a different Unix socket for each version being run.)

Ken

1 Like

yes, you’re right. I solve this issue. Thanks a lot.