If you can’t remember your PostgeSQL database account password you
will need to disable authentication temporarily, login and reset the
password.
Disable Authentication
1. Go into your PostgreSQL data directory. The data directory can be located in
Microsoft Windows - C:\Program Files\PostreSQL\8.3\data\
Ubuntu Linux - /var/lib/postgresql/data/
RHEL/Fedora - /var/lib/pgsql/data
2. Open pg_hba.conf in any text editor, and in the last 2 lines, replace "md5" with "trust"
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 md5
3. Restart your PostgrSQL database service.
Reset Password
1. Log into PostgreSQL admin console,
Windows - Start → Program Files → PostgreSQL → PgQdmin III
Linux - Open "psql" in command prompt.
2. Choose "postgres" database and execute following SQL query -
Alter user <postgres username> with password 'foobar';
3. Quit PostgreSQL admin console
Enable Authentication
1. Change the lines in pg_hba.conf from "trust" to "md5" .
2. Restart your PostgrSQL database service.
Try logging in and see if your change worked!