It appears you are confusing two things:
postgres
the system user
postgres
the SQL database user
The only relation between both is that at PostgreSQL installation, the database user postgres
is authenticated with the peer authentication method: the database server checks that the system user requesting access to the database as database user postgres
is also called postgres
. Also, the database server itself runs as the system user postgres
.
It's not possible from the database to alter the system. Giving a password on the database account will not alter the fact that the system user postgres
has no sudo rights, and most certainly a disabled password, thus allowing only root to use it by default (but not the reverse).
So, if you want to become root
, you cannot do this from the postgres
system account, and that's a good thing: should ever the database server (its processes also running as system user postgres
) be compromised, there will be no way to escalate to root
access from it.
Just login again to the account you used to install postgreSQL: either directly the root
account (usually not done on Ubuntu) or (usually done on Ubuntu) the user configured at installation of the system, with uid 1000, which on Ubuntu is allowed by default to do sudo su -
.