I just done a clean install of postgressApp and the app says connected and started on port 5432. However the terminal gives me something like this:
Last login: Mon Feb 29 22:45:28 on ttys006
'/Applications/Postgres.app/Contents/Versions/9.5/bin'/psql -p5432
➜ ~ '/Applications/Postgres.app/Contents/Versions/9.5/bin'/psql -p5432
psql: FATAL: role "me" does not exist
➜ ~
Before installing I removed postgress brew and enterprise psql
By default, psql tries to connect to the PostgreSQL server using the same user name as your system user. So in order to make connecting easier, Postgres.app creates a user with the same name as your system user when it starts the first time.
If you change your system user name, those user names won't match anymore. Then you have to connect using psql --username=OLDUSERNAME, or with psql --username=postgres to connect as the postgres user.
psql also uses your environment variables for configuration. So for troubleshooting, type export in Terminal to make sure there are no settings for PGUSER etc. that override the defaults.
Hi, and thx, when I do export I get
USER=me
I'm not sure what to do about the role error.
So I assume your local username is "me". Did you ever change that?
Try the following:
1) quit Postgres.app
2) delete the data directory (~/Library/Application Support/Postgres -- check the docs for details)
3) then start Postgres.app again
Then it should create a new data dir and create a postgres user (role) with the name "me", and it after tht you should be able to connect
Just had the same issue after installing Postgres 9.5.1.0. What I did:
ps aux | grep postgres)mv /Applications/Postgres /Applications/Postgres-9.4)mv ~/Downloads/Postgres /Applications/Postgres)Result:
➜ ~ /Applications/Postgres.app/Contents/Versions/9.5/bin/psql
psql: FATAL: role "chrisdonadeo" does not exist
➜ ~ /Applications/Postgres.app/Contents/Versions/9.5/bin/psql -U postgres
psql (9.5.1)
Type "help" for help.
postgres=# SELECT rolname FROM pg_roles;
rolname
----------
postgres
(1 row)
It appears that no role with my username was created when the database was initialized. I think I recall that this did happen with 9.4 versions, and the documentation states that you should use your username and a blank password.
Well, first of all you can of course create a new user and corresponding database using the folowing two commands:
createuser -U postgres -s YOURUSERNAME
createdb YOURUSERNAME
This is what Postgres.app should have done right after initialising the data directory.
So it would be interesting why creating the user failed in the first place -- Postgres.app should show an error if it fails to create the user.
For troubleshooting purposes, could you try the procedure I suggested above (quit Postgres, delete or move data dir, start Postgres again) to see if initialisation works properly? Also, check the log file inside the data dir to see if there's anything that could explain this...
@jakob, thx but after deleting ~/Library/Application Support/Postgres and restarting I get the same error. And now I did not change "me".
@es6Test
did you get any errors? are you able to connect using psql -U postgres?
Can you try the following command and see what happens?
psql -U postgres -c 'SHOW data_directory;'
Also, is there anything in the log? You can view it using
cat ~/Library/Application\ Support/Postgres/var-9.5/postgres-server.log
(Assuming you are running 9.5 and using the default data dir)
I had to add this to the path:
export PATH="/Applications/Postgres.app/Contents/Versions/9.5/bin:$PATH"
`➜ ~ psql -U postgres -c 'SHOW data_directory;'
/Users/me/Library/Application Support/Postgres/var-9.5
(1 row)`
LOG: using stale statistics instead of current ones because stats collector is not responding
LOG: received fast shutdown request
LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
LOG: database system was shut down at 2016-03-05 09:13:16 GMT
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
FATAL: role "me" does not exist
thx 4 helping!!
I noticed I have a user call postgres, how can I tell psql to use that instead of 'me'?
the postgres user is part of group daemon
I ran psql manually in the terminal by supplying -U postgres
I was having the same issue and quitting the new install (9.5), deleting the ~/Library/Application Support/Postgres/var-9.5 directory and relaunching fixed it.
These are steps how i solved this issue on Windows
How to setup POSTGRES DB
If you have password error then do this
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
First of all add path of POSTGRES
Add to Enviroment Path
Now you can run POSTGRES QURIES through CMD on windows
Open CMD and type
Most helpful comment
Well, first of all you can of course create a new user and corresponding database using the folowing two commands:
This is what Postgres.app should have done right after initialising the data directory.
So it would be interesting why creating the user failed in the first place -- Postgres.app should show an error if it fails to create the user.
For troubleshooting purposes, could you try the procedure I suggested above (quit Postgres, delete or move data dir, start Postgres again) to see if initialisation works properly? Also, check the log file inside the data dir to see if there's anything that could explain this...