Saturday, December 24, 2011

[PostgreSQL][Mac] Modify root password (Forgot password)


  • sudo su postgres
  • supply your Mac password
  • modify /Library/PostgreSQL/9.x/data/pg_hba.conf
    • from local all all   md5
    • to local all all   trust
  • execute /Library/PostgreSQL/9.x/bin/pg_ctl restart -D /Library/PostgreSQL/9.x/data/
  • run psql
  • change postgres password
    • ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';
  • modify pg_hba.conf back
  • restart again
Tested with PostgreSQL version 9.1 OSX Lion

6 comments:

Steve said...

This totally worked for me! Thanks!

Ray said...

I'm a bit stuck here. Can you help? Thanks

execute /Library/PostgreSQL/9.x/bin/pg_ctl restart -D /Library/PostgreSQL/9.x/data/

I just went into the file and double clicked on the pg_ctl and it executed..
afterwards how do you restart it? I've tried restarting the postgres.app and tried running sql but it still requires me to enter in a password....

Unknown said...

Bump. Running PostgreSQL 9.3 on Mac OSX 10.9.5

Modified the .conf file as directed, restarted the server and reloaded the configuration but can't get to psql from the command line and running psql from Applications/PostgreSQL 9.3 GUI launcher requires the postgre user pw -- that I'm trying to change because I'm an idiot and misplaced it and forgot it after a fresh install.

Unknown said...

Thank you so much! There is so much bad info on the web but thankfully I found this. It worked perfectly. =)

Unknown said...

Thanks for your help, I was stuck with this problem, and didn't know that the password is simply the mac pass. Thank you so much

Unknown said...

please help
I have it written "denied available" after entering /Library/PostgreSQL/12/data/pg_hba.conf

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresql