Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How do I find out what is my database's username in my local machine? I'm updating my database.yml file in my rails application, but anything I try isn't working.

When trying to use postgres (or other options such as mymacusername) I'm getting the following error:

FATAL:  role "postgres" does not exist

Do I need to create it? How? Or can I use an existing username on my computer?

Update: I am trying to create a user (this is soon after installation so the issue may be that it doesn't exist yet) I ran createuser -s -U $USER Name of role to add: postgres

But am getting the following error:

createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

So this is the problem - How do I make it listen to the correct socket?

share|improve this question

1 Answer 1

if you have root access:

sudo -u postgres psql DATABASENAME

inside it type

\l

to show all databases and its users

share|improve this answer
    
I have admin access. I tried that and got sudo: unknown user: postgres –  Lucy Weatherford Apr 24 '13 at 7:59
    
try to look at here –  Alive Developer Apr 24 '13 at 8:23
    
Thanks, that seems to be the problem, but the solution isn't there - how can I find that socket and get it to listen to it? I am trying sudo find / -name .s.PGSQL.5432 -ls but not sure how to get postgres to talk to it –  Lucy Weatherford Apr 24 '13 at 8:37
    
See update to the question –  Lucy Weatherford Apr 24 '13 at 8:42
    
netstat -nlp | grep postgre . The listening port should be the last number. There should be more than 1 entries in the result –  Alive Developer Apr 24 '13 at 8:44

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.