I have a postgres server and I don't want django to login as postgres user, so I created a user called django with createuser --interactive -P django
.
I want to login as django over ssh but when I try psql -U django -W
it gives me this error:
psql: FATAL: Peer authentication failed for user "django"
You have to authorize your new user to connect to database by editing your pg_hba.conf
file (often located on /etc/postgresql/9.4/main/pg_hba.conf
with 9.4
being your installed version of PostgreSQL).
Do to so, add a line on it like this one :
# TYPE DATABASE USER ADDRESS METHOD
local django django trust
Supposing that you created a database name django
for your django
user. It only allow your user to connect locally, if you want to allows him to connect via TCP/IP, line is more like
# TYPE DATABASE USER ADDRESS METHOD
host django django 192.168.12.10/32 md5
Where 192.168.12.10
is the IP from where your django
user will reach your database.
Read comments on pg_hba.conf
file, they explain pretty well how it works. Or have a look at this documentation on PostgreSQL website.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments