Find pg_hba.conf, if you can connect to db template1, you can use this command.
psql -d template1
show hba_file;
Command above will result /etc/postgresql/10/main/pg_hba.conf for default postgresql installation.
Edit pg_hba.conf, search for # IPv4 local connections, insert this value :
host all username 127.0.0.1/32 trust
Restart postgresql
sudo service postgresql restart
After that you can connect or execute any psql command without password.
zuka.one
©2011