You may grant yourself the necessary permissions assuming you have the right to edit PostgreSQL configuration under /etc/postgresql
.
First, check what version of PostgreSQL is installed and the name of the cluster/instance (see the output of pg_lsclusters
). For instance with Ubuntu 16.04 the version would be 9.5
with the default repository because that's what was current in 2016, and the instance would be named main
.
In this case, the configuration is under /etc/postgresql/9.5/main
(otherwise change the path according to version/cluster). In the configuration, you may declare a mapping from your Unix user name to the postgres superuser database account, for instance:
In /etc/postgresql/9.5/main/pg_ident.conf
# MAPNAME SYSTEM-USERNAME PG-USERNAME
mymap myusername postgres
In /etc/postgresql/9.5/main/pg_hba.conf
, as the first rule (the order does matter):
# local DATABASE USER METHOD [OPTIONS]
local all postgres peer map=mymap
Then reload (sudo pg_ctlcluster 9.5 main reload
), and the Unix myusername
account should be able to connect locally as superuser with:
$ psql -U postgres -d postgres
Otherwise check the server logs under /var/log/postgresql