Reputation: 555
What does the below command mean that you "login as root"? I don't understand when do you create a user or when you don't have to. If you're logging in as root, does that mean you're just the official super user or something that can create all other users? What's the difference between this and creating other users/roles? If I can get an analogy to understand that would be great.
su - postgres
Upvotes: 1
Views: 8662
Reputation: 324295
It switches your unix user and unix shell to the unix postgres
user. That's all.
(Don't do that, use sudo -u postgres
instead).
At a guess, you're doing that because you then want to run psql
. By default on most installs psql
will connect to postgres with the same postgres username as your unix user name. So switching to unix user postgres then runnining psql will get you a postgres session as the postgres user, which usually has superuser rights to the database.
Upvotes: 1