I accidentally set password to blank for a PostgreSQL database, how do I change it?
This blogpost should answer. Full disclosure: it's my blogpost.

Summary:


  If you have access to shell account on the machine PostgreSQL is running, and your shell works as the same user as Postgres itself, or root – solution is easy.
  
  Edit your pg_hba.conf file, and at the beginning of it put:
  
  local all all trust
  
  or (depending on your paranoia):
  
  local all postgres ident
  
  And restart your PostgreSQL (usually something like /etc/init.d/postgres restart).
  
  Afterwards you should be able to connect to Postgres as postgres user without password.
  
  You should note, that if you have choosen the option with “ident” you will be able to connect without password only from shell account named “postgres”.
  
  don't forget to reverse the pg_hba.conf settings when you have reset the password.