2

I just installed postgres (with brew) and started it with pg_ctl -D /usr/local/var/postgres -l logfile start

I now try to connect to it in the terminal but get the following:

Connection to PostgreSQL - postgres@localhost failed FATAL: role "me" does not exist

The issue might be that I first installed postgres.app and then didn't get it work right and then removed it.

SuperUberDuper
  • 9,242
  • 9
  • 39
  • 72
  • The account you should be using initially is `postgres` and it should not require a password. – Nick Jul 15 '16 at 16:32
  • I run 'su postgres' then `initdb /usr/local/var/postgres9.5 -E utf8` but I get `creating directory /usr/local/var/postgres9.5 ... initdb: could not create directory "/usr/local/var/postgres9.5": Permission denied` – SuperUberDuper Jul 16 '16 at 08:42
  • for some reason when I run initdb I got the var/postgres dir created with user root – SuperUberDuper Jul 16 '16 at 08:44
  • actually, I just checked the users on my mac, I have a postgresql user, I think its because I started with postgres.app and then switched to brew and it just confused things, not sure what to do now @Nicarus – SuperUberDuper Jul 16 '16 at 08:46

1 Answers1

3

You don't show what you typed and as which user you did it, but from the error message I'd say that you should add -U postgres to the psql invocation.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • enjoy the easiest bounty ever.. probably – SuperUberDuper Jul 18 '16 at 14:28
  • Well, if it did the trick for you, that's mission accomplished. If not, please tell me more details. – Laurenz Albe Jul 18 '16 at 15:37
  • I can award in 15hrs – SuperUberDuper Jul 18 '16 at 16:01
  • for some reason I am now getting `FATAL: role "postgres" does not exist` any easy way to resolve? – SuperUberDuper Jul 19 '16 at 13:19
  • Did you `DROP USER postgres` or something? If you have no superuser in the database, you'll have to stop the server, start it in single user mode as described [here](http://stackoverflow.com/questions/27777076/accidently-removed-postgres-default-superuser-privileges-can-i-get-it-back/27778321#27778321), then look with `SELECT * FROM pg_authid` and recreate the user if necessary. – Laurenz Albe Jul 19 '16 at 14:14