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?
Solved this on @CraigRinger's advice by running a fresh initdb
in a new directory.
Note: Deleting your data dir and running a new initdb
will destroy all existing data, so it's not something you should do if there's anything in your PostgreSQL install you care about.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.