0

I have lost my password for PostgreSQL. I have already tried googling around a bit, however the

local all all trust

solution didn't work for me. Does anyone know how to recover / reset this password in another way? Thanks!

EDIT

Here is the error I received:

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

I did try out the solution posted here I forgot the password I entered during postgres installation

Community
  • 1
  • 1
JasperMW
  • 465
  • 3
  • 7
  • 22
  • what exactly did not work?.. errors? – Vao Tsun Apr 11 '17 at 12:56
  • What is the `local all all trust` solution that has failed? Please be more specific. Are you saying you've followed the steps in [this linked question](http://stackoverflow.com/questions/10845998/i-forgot-the-password-i-entered-during-postgres-installation)? – CalvT Apr 11 '17 at 12:56
  • [here](http://dba.stackexchange.com/questions/19643/how-do-i-reset-the-postgres-password-for-postgresql-on-windows) and [here](http://dba.stackexchange.com/questions/44586/forgotten-postgresql-windows-password) – McNets Apr 11 '17 at 12:58
  • "*Connection refused*" means that Postgres isn't running. That has nothing to do with a wrong password. –  Apr 11 '17 at 13:05
  • 1
    I think he is trying to connect using TCP/IP, but this pg_hba.conf is for __unix socket connections only__. – Łukasz Kamiński Apr 11 '17 at 13:45
  • add `host all all 0.0.0.0/0 trust` to hba.conf, then `pg_ctl reload` and try again. after changing the password, remove the line – Vao Tsun Apr 11 '17 at 14:17
  • I still haven't been able to fix this. However, I'll look more into the "Postgres not running" comment. Maybe that will solve it. – JasperMW Apr 11 '17 at 15:50
  • As 'a horse with no name' said, this means the Postgres server isn't running. If on windows, go to Computer Management, Services And Applications, Services, and find Postgres. . .Start the server and it should not ask for a password anymore. – Chris Kavanagh Sep 15 '19 at 02:44

1 Answers1

0

I assume you are referring yourself to the procedure described here:

http://www.postgresqltutorial.com/postgresql-reset-password/

Actually the described procedure is a bit wrong, as you should not add the line "local all all trust" after the comment lines, but rather modify all the methods from "md5" to "trust". Doing so I could connect to the server without indicating a password and then I could reset the password.

On windows I had to change the lines "host all all 127.0.0.1/32 md5" to "host all all 127.0.0.1/32 trust".

Hope that helps

ZKB
  • 101
  • 2