Search code examples
postgresqlubuntupsql

How to start a psql command line?


I'm trying to create a postgresql user and password. This tutorial supplies the command to create a user, but I can't find anywhere how to actually start the psql command line, where I would then run the CREATE USER command.

How can I start a psql command line? I'm using Ubuntu 14.04.

I tried just running psql, but I get back

psql: FATAL:  role "user" does not exist

But I can't create a user without logging into the command line...


Solution

  • psql if run by default without any arguments takes the current user name which obviously does not exist, since you just installed a postgresql.

    From the other hand ubuntu's postgresql distribution comes with a default postgres user created (both in system and in postgresql databse). Which means that if you run a psql command on behalf of a postgres user then you would be able to connect:

    sudo -u postgres psql