Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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'm using PostrgreSQL 9.1.9 on Ubuntu 13.04.

Using the following StackOverflow question, I tried to create a user/role in postgressql:

giladnaaman@giladnaaman-Lenovo-G550:~/Programming/Eclipse/Hephaestus$ createuser --version
createuser (PostgreSQL) 9.1.9

giladnaaman@giladnaaman-Lenovo-G550:~/Programming/Eclipse/Hephaestus$ createuser f4
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) y
createuser: could not connect to database postgres: FATAL:  role "giladnaaman" does not exist

How can I solve this problem?

share|improve this question

migrated from Apr 27 '13 at 20:27

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

up vote 2 down vote accepted

You are trying to connect to the database as your user but that use doesn't exists. The best way to execute administrative commands on PostgreSQL is to issue them as the "postgres" user. Change user with:

sudo su -  postgres

The user postgres exists and has administrative privileges (it is a superuser) so can connect the database and create new users (just do a createuser after the sudo).

share|improve this answer
As an alternative you can just specify --username=postgres as a parameter to the createuser command – a_horse_with_no_name Apr 29 '13 at 6:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.