I'm using Postgres 9.4 on Debian Linux. I created a database with a user, cindex
with access to the database. Yet when I try and login at the command line, I'm not even prompted for a password:
myuser@myuserserver:~ $ psql -Ucindex cindex
psql: FATAL: Peer authentication failed for user "cindex"
What else do I need to do to enable the user? Below you can see the privileges that I have already set up:
postgres@myuserserver:~$ psql
psql (9.4.13)
Type "help" for help.
postgres=# GRANT SELECT ON ALL TABLES IN SCHEMA cindex TO cindex;
GRANT
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
cindex | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =T/postgres +
| | | | | postgres=CTc/postgres+
| | | | | cindex=c/postgres
postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
cindex | | {}
postgres | Superuser, Create role, Create DB, Replication | {}
pg_hba.conf
. Think of it as the PostgreSQL server firewall configuration.peer
orident
authentication. Those don't use passwords, so there is no point in asking you for a password. You are looking to changepeer
orident
to bemd5
, which does use passwords. (or perhaps toldap
, or `scram-sha-256 (v10 only), or maybe one of the more obscure methods which uses passwords)