1

To access psql, I have to first login to another Unix account

sudo su - postgres

then I can do

postgres@linux ~ $ psql
psql (9.1.10)
Type "help" for help.

postgres=#

However, I don't understand why the postgres Unix account (when I do sudo su - postgres) is necessary. What's wrong with just running "psql" from my original Unix account?

And do the postgres Unix and command line share the same password?

*I'm pretty new to Linux/postgres, so feel free to give fundamental explanations

EDIT: another question: What's the difference between

postgres=#

and

postgres-#
3
  • 2
    You don't need to use sudo, you can start psql -U postgres to log in as the postgres user. Commented Nov 8, 2013 at 23:01
  • @a_horse_with_no_name I'm asking why the postgres Unix account is needed in the first place. Why can't I go directly to the "postgres=#" command line from the user@linux I was originally using? Commented Nov 8, 2013 at 23:09
  • You can do that, and a horse with no name told you how to. Commented Nov 9, 2013 at 0:12

1 Answer 1

5

However, I don't understand why the postgres Unix account (when I do sudo su - postgres) is necessary. What's wrong with just running "psql" from my original Unix account?

And do the postgres Unix and command line share the same password?

The Postgres user can't log in and only reads/writes to whatever it owns, unless you create it or configure your computer otherwise otherwise.

And therein lies the reason for it to be around: security. It's not technically required (as an example, homebrew on OSX will use your own username), but best practice -- especially on a server.

Sign up to request clarification or add additional context in comments.

2 Comments

Is the only purpose to make sure that you don't modify anything other than postgres files?
And not giving login or shell access to Postgres, yes. One word: security.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.