I'm trying to get PostgreSQL setup on a new (Linux Mint) computer. Everything works great until I try to access the database. When I do, as my own user, I get the following (expected) error:
$ psql
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "me" does not exist
That makes sense, because on Linux there's a separate postgres user with DB access. I tried using them instead:
$ sudo su postgres
[sudo] password for me:
$ psql
Password for user postgres: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
At this point I became confused: the postgres user is supposed to have password-less access to all PostgreSQL databases. Furthermore, I tried setting my pg_hba.conf file to allow all users local access:
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
However, even after I restarted PostgreSQL (with /etc/init.d/postgresql reload) I still was prompted for a database password for user postgres.
Can anyone help me understand:
- Why am I getting prompted for a password when I try to access my database as the
postgresuser (on a fresh install)? - Why do I still get prompted even after setting IPv4/IPv6 local connections to
trust? - How can I fix my
postgresuser to be like other Linux boxes (ie. not have any database password, but still be able to access all DBs)
FATAL: role "me" does not existYou're using the wrong user. Be specific in your commands for psql, something like this:psql -p 5432 -h localhost -U postgres -d your_database_nameThis command uses the superuser "postgres" and not your default user "me"meuser can't access: that's expected (please read the full question). What I don't understand is why thepostgresuser can't access. Also, just to clarify, when I'm logged in as the (system) userpostgres, I shouldn't need-U postgres(because the database user is inferred to be the system user).socket. You didn't setlocalin your configuration. Add this to pg_hba.conf or use a TCP/IP connection like my example.