Is there a way to break into a PostgreSQL database if you forgot the password?

后端 未结 2 876
生来不讨喜
生来不讨喜 2021-02-02 14:50

I have a client that has a PostgreSQL database and he cannot remember the password that we used when the database was setup. Is there a way to recover that information so I do n

2条回答
  •  感动是毒
    2021-02-02 15:11

    For 9.2, in windows:

    Stop the service:

    Net stop postgresql-x64-9

    Modify the config file, change data/pg_hba.conf, basically md5 to trust:

    host all all 127.0.0.1/32 trust

    host all all ::1/128 trust

    Start the service:

    Net start postgresql-x64-9

    Execute the sql statement to set your desired password, on a sql console or using psql:

    alter user postgres with password ‘newpassword’;

    Put back the original config file.

提交回复
热议问题