I installed the postgresql rdbms using standard:
sudo apt-get install postgresql
and now I can see the binary:
-rwxr-xr-x 1 root root /usr/lib/postgresql/12/bin/postgres
which means the root user own it.
HOWEVER: in the docs
You will need to become the operating system user under which PostgreSQL was installed (usually postgres)
I had to switch to postgres user to be able to connect to the server to create new role with my name.
So can anyone explain this contradiction? Or am i missing something?
CodePudding user response:
When you do:
sudo apt-get install postgresql
it is installing the package(postgresql) files as the root user. The install will also create a system user postgres. When the server cluster is created it will be done with the files assigned the postgres user rights per Create cluster and it will be run as the postgres user per Running server. In fact Postgres will refuse to run as the root user. To see what user the server is running as do:
ps aux | grep postgres
Now in addition to the system user postgres a database user postgres is also created. It is not strictly necessary to become the system user postgres to connect to the database, all you need to do is connect as the database user postgres by using -U postgres with psql.
FYI, the use of the name postgres as the user is a convention and not a requirement, so you may see some exceptions in other packaging systems. For instance the MacOS package postgres.app makes the name the system user name you installed as.
