Skip to main content
2 of 3
added 591 characters in body
Evan Carroll
  • 64.7k
  • 49
  • 251
  • 496

Check your PostgreSQL pg_hba.conf. It should have lines like this copied directly from the docs.

# Allow any user on the local system to connect to any database with
# any database user name using Unix-domain sockets (the default for local
# connections).
#
# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             all                                     trust

# The same using local loopback TCP/IP connections.
#
# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             127.0.0.1/32            trust

You don't have to keep these. But it's normal to have these so you can connect locally without having to worry about passwords using your local system authentication methods. This will allow you to log in s any user.

So you can log in as PostgreSQL with,

sudo -u postgresql psql -d myDatabase
Evan Carroll
  • 64.7k
  • 49
  • 251
  • 496