0

I installed postgres in my rails application, but I cannot create any roles. For su - postgres and psql -d template1 -U postgres I get psql:FATAL role "postgres" does exist I also ran createuser -s -U $USER

What am I doing wrong? Thanks!

Bogdan Popa
  • 1,099
  • 1
  • 16
  • 37

1 Answers1

0

Here's a list of already answered questions:

Depending on how you installed PostgeSQL, you may not have the role postgres. For instance, on my machine, when I install PostgreSQL via Homebrew, the install creates the default user as the current logged in user, not postgres.

Therefore, to login I must use

psql -U <myuser> -h localhost

and not

psql -U postgres -h localhost

You may get the error

psql: FATAL:  database "<user>" does not exist

In that case, follow the instructions in this topic to create the user database.

Community
  • 1
  • 1
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • thanks for the info, I tried with `sudo -i -u postgres` `createuser --interactive`. it prompts the question shall the new role be a superuser? I press y and then I get `psql: FATAL: role "bogdan" does not exist`. – Bogdan Popa Nov 24 '14 at 11:26
  • Where does `sudo -i -u postgres` come from? I never mentioned it. Please read my answer and the associated answers. – Simone Carletti Nov 24 '14 at 11:38