0

I already have a rails project then i installed Postgresql and pgadmin III , I need to use posgresql in development instead of sqlite and production to use heroku , I followed the answer number two in this question Change from SQLite to PostgreSQL in a fresh Rails project because i just installed Postgresql using synaptic center without making anything else , when i try to create a user i got an error:

createuser dexter
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 "dexter" does not exist
Community
  • 1
  • 1
Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61
  • does 'sudo -u postgres createuser' work? – Drew Aug 08 '13 at 20:06
  • but why should i create a new user without superuser role ? can you explain it for me ? because i found all answers and from searching on google doing the same step `Shall the new role be a superuser? (y/n) n` without explanation – Mostafa Hussein Aug 08 '13 at 21:17
  • Hi, Mostafa, please see my updated answer. – Drew Aug 08 '13 at 21:42

1 Answers1

0

use:

$ sudo -u postgres createuser

To answer your question, from the postgresql documentation:

"If you wish to create a new superuser, you must connect as a superuser, not merely with CREATEROLE privilege. Being a superuser implies the ability to bypass all access permission checks within the database, so superuserdom should not be granted lightly."

Given that the account you are creating is simply for granting your Rails application access, while the ability to create databases makes sense, superuser privileges is not a good idea.

Drew
  • 2,601
  • 6
  • 42
  • 65
  • I want to make my user as a blank password to use rails without out password , should i add something in sudo -u postgres createuser ? – Mostafa Hussein Aug 09 '13 at 02:27
  • See this question as a starting point for what you are trying to do: http://stackoverflow.com/questions/5421807/set-blank-password-for-postgresql-user – Drew Aug 09 '13 at 11:38