I recently installed postgres version 9.3.5 on osx 10.10 and I am unable to connect to it with psql. I started the server as my own user as follows:
jestep$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
With pg_ctl status I confirmed the server was running. However I cannot connect to the server regardless of what username I try.
jestep$ psql
psql: FATAL: role "jestep" does not exist
jestep$ psql -U postgres
psql: FATAL: role "postgres" does not exist
jestep$ psql -U _postgres
psql: FATAL: role "_postgres" does not exist
jestep$ psql -U admin
psql: FATAL: role "admin" does not exist
jestep$ psql -U root
psql: FATAL: role "root" does not exist
Here are the contents of my pg_hba.conf file:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
I have checked in /etc/passwd, and there is no user called postgres, though there is _postgres.
This happened to me once before on Ubuntu and I actually had to uninstall postgres and all extensions, reinstall them, and initialize a completely new database. Is there any less drastic approach I can take?
initdb? If you raninitdbyourself then the superuser role will be the same name as the user who raninitdb, unless you passed an explicit-Uparameter toinitdb. If all else fails you should either (a) delete the datadir and re-initdb, if there's nothing on there you care about, or (b) start PostgreSQL in single-user mode and create a new role.initdb -D ~/.local/pgsql. The output told me that the server would be owned by userjestep. However I cannot connect to it asjestepor aspostgres, both times it claims the user does not exist.