Background
I am new to Postgres and currently going through the documentation as I'm learning to use it. I am having trouble understanding the Postgres user.
I noticed that I can run psql postgres
without inputting any kind of password, and I have the power to create and alter users. I was trying to determine whether it is normal for the user postgres to have no password or if I should set one manually.
What I've Tried
I tried to find an explanation on the Postgres 15 documentation but was only able to find a limited explanation here. The documentation is pretty expansive so despite my best efforts I haven't been able to find a better explanation.
I also found this question where the top answer said you can determine the username using \du
. When I ran this command, it outputted my computer username instead of "postgres" and indicated I'm a superuser.
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
ciesinsg | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
Question in a nutshell
So my question is what is this postgres user, and is it safe to leave it without a password?
Additional Info
I am using PostgresQL@15 installed using homebrew on M2 MBP.
I also understand that it is advisable to set up new users and set them as owners in new databases. I am just worried that the lack of authentication on the postgres user may result in a bad actor altering my existing users if I don't take precautions.
Clarification *
This question is based on my incorrect interpretation of the PostgreSQL getting started documentation. I am posting this clarification without editing the question in case anyone else is similarly confused.
psql postgres
actually connects to the postgres database, and not the postgres user. As per Ardian's reply, this homebrew documentation outlines how the formula sets up the database and ownership.