To connect to Postgres, you first need to give the default Postgres admin user postgres
a password using sudo passwd postgres
. Then run the psql
command with the postgres
identity using sudo -u postgres
.
Create a user
If you don’t want to use the default postgres
admin user. You can create your own admin user by following the steps below.
Then edit pg_hba.conf
, which is located in /etc/postgresql/<version>/main
.
Scroll to the bottom of the file and change all the peer
to trust
.
References