Rails and PostgreSQL: Role postgres does not exist
Actually, for some unknown reason, I found the issue was actually because the postgresql role hadn't been created.
Try running:
createuser -s -r postgres
Note that roles are the way that PostgreSQL maintains database permissions. If there is no role for the postgres user, then it can't access anything. The createuser command is a thin wrapper around the commands CREATE USER, CREATE ROLE, etc.
Recently i got this problem immediately after installing postgres.If it comes immediately after installation, you might be missing the default user, postgres.In that case, you can create default user postgres using below command.
createuser -s -U $USER
Ex: createuser -s -U $USERenter your required role name: postgresenter password for your the user:
It will prompt you to enter required database role name and passwordOnce you complete the process, you can login to the postgres console using below command
psql -U 'your_database_name'
Ex: psql -U postgres
Here, You need to enter the password if you have given any, while creating the user.
Hope it helps :)
I was on OSX 10.8, and everything I tried would give me the FATAL: role "USER" does not exist
. Like many people said here, run createuser -s USER
, but that gave me the same error. This finally worked for me:
$ sudo su# su postgres# createuser -s --username=postgres MYUSERNAME
The createuser -s --username=postgres
creates a superuser (-s flag) by connecting as postgres (--username=postgres flag).
I see that your question has been answered, but I want to add this answer in for people using OSX trying to install PostgreSQL 9.2.4.