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. You also don't need both of these. If you only ever connect over sockets, feel free to nuke the one with tcp. This will allow you to log in swith any locally authenticated user.
So you can log in as PostgreSQL with,
sudo -u postgresql psql -d myDatabase
or using tcp
sudo -u postgresql psql -d myDatabase -h 127.0.0.1