Sunday, January 16, 2011

PostgreSQL Commands

I lost the database password. What can I do to recover it?

You can't. However, you can reset it to something else. To do this, you
  • edit pg_hba.conf to allow trust authorization temporarily
  • Reload the config file (pg_ctl reload)
  • Connect and issue ALTER ROLE / PASSWORD to set the new password
  • edit pg_hba.conf again and restore the previous settings
  • Reload the config file again