Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am about to deploy my app to a vps for the first time, and running into some issues while configuring my DB.

After running the following commands...

# PostgreSQL
add-apt-repository ppa:pitti/postgresql
apt-get -y update
apt-get -y install postgresql libpq-dev

everything seemed to work fine until

sudo -u postgres psql

I was supposed to login to psql, but the command did not do anything (didn't return anything). I tried

su postgres

instead, and it got me to postgres@myaccount:/root$

and then I tried

sudo postgres psql

and it asked me for the password, but the root password did not work for this.

What's the right way of logging into postgres in this case, and how do I set up my database?

UPDATE: I tried the following,

root@max:~# su postgres
postgres@max:/root$ psql
bash: /usr/bin/psql: /usr/bin/perl: bad interpreter: permission denied
share|improve this question

migrated from Dec 3 '12 at 23:38

This question came from our site for professional and enthusiast programmers.

up vote 0 down vote accepted

I think psql is supposed to run as postgres user . You should not type 'sudo' .

root@myaccount:/root$ su postgres
postgres@myaccount:/root$ psql 
share|improve this answer
when I do psql create user, it gives me usr/bin/perl: bad interpreter: permission denied – Maximus S Dec 2 '12 at 1:03
When you issue 'psql' command as a postgres user , it takes you to command prompt . There you should type : create user your_user with password 'password'; (notice the semicolon at the end of the sql command). In case the user is created successfully , you should see something like CREATE ROLE. – Qumara otBurgas Dec 2 '12 at 1:09
check my update please – Maximus S Dec 2 '12 at 1:15
As 'postgres' , what does $ echo $PATH shows ? Is your perl package installed ? (on debian : apt-cache policy perl) – Qumara otBurgas Dec 2 '12 at 1:19
Installing perl solved the problem! – Maximus S Dec 2 '12 at 1:38

You must log in to answer this question.