I am unable to login and use a created database because I either receive a password or peer authentication failure. Below outlines how I set things up, how I've tried to fix the encountered issues, and further potentially relevant information.
I am using postgresql-9.5
, and when I downloaded postgres, it was with a different linux mint user/username than I am currently attempting to access it from. All commands below were sent from the new user/username.
I created a new postgres database and a new user with a password with the following commands: sudo su - postgres
$ psql
postgres=# CREATE DATABASE PostgresDB;
postgres=# CREATE USER PostgresUser WITH PASSWORD 'password';
postgres=# ALTER ROLE PostgressUser SET default_transaction_isolation TO 'read committed'
postgres=# GRANT ALL PRIVILEGES ON DATABASE PostgresDB TO PostgresUser;
I then proceeded to attempt a login in a number of ways:
psql -d PostgresDB -U PostgresUser
Returns: psql: FATAL: Peer authentication failed for user "PostgresUser"
psql -d PostgresDB -U PostgresUser -W
and password entrypsql -d
,psql -U PostgresUser -h 127.0.0.1 -d PostgresDB
and password entry
Each Returns: psql: FATAL: password authentication failed for user "PostgresUser"
I made all of the above attempts to login before and after resetting the password with: ALTER PostgresUser WITH PASSWORD 'password'
I have checked the pg_hba.conf file, the important parts of which, read:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# 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 md5
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5