1

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?

2 Answers 2

1

if you have root access:

sudo -u postgres psql DATABASENAME

inside it type

\l

to show all databases and its users

Sign up to request clarification or add additional context in comments.

10 Comments

I have admin access. I tried that and got sudo: unknown user: postgres
try to look at here
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
netstat -nlp | grep postgre . The listening port should be the last number. There should be more than 1 entries in the result
netstat: option requires an argument -- p
|
0

We simply need to create postgres role. Commands to create a role name postgres: 1.sudo -u postgres psql 2.CREATE ROLE postgres WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'password'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.