I installed postgres
with Django
following this guide
Here I created a database and a user in the postgres
command line :
CREATE DATABASE myProject;
CREATE USER myUser WITH PASSWORD '1234';
When I try to connect to this database, either through Django
or directly via pscopg2
I get the wrong password error.
#connect through python
import psycopg2
psycopg2.connect("dbname=myProject user=myUser host=localhost password=1234 port=5432")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/project/venv/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "myUser"
FATAL: password authentication failed for user "myUser"
In this question I've replaced my actual project names, user name and password. But I've double, triple checked and the names/passwords I'm writing down are all correct.
How am I getting a bad password request? How can I fix this?
EDIT: The contents of my pg_hba.conf
file:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5