Change/reset postgresql user password on windows 7

前端 未结 5 1186
余生分开走
余生分开走 2021-02-01 17:43

Several days ago I install postgesql 9.2 version on my local computer. (OS windows 7)

Now I forgot my password and I can not login in pgAdmin.

How to change pos

相关标签:
5条回答
  • 2021-02-01 18:10

    Run your psql executable file and login into your database using your old password, use the following command to login:

     .\psql.exe -U postgres
    

    Then use

    ALTER USER <user_name> WITH PASSWORD <'new_password'>
    

    For more information refer this link : https://www.postgresql.org/docs/8.0/sql-alteruser.html

    0 讨论(0)
  • 2021-02-01 18:21

    In windows postgres stores password for automatic login at following path (only if you would have selected password save option while installation)

    C:\Users\USERNAME\AppData\Roaming\postgresql\pgpass.conf

    you can open this file in a text editor and see your password.

    0 讨论(0)
  • 2021-02-01 18:31

    In the pg_hba.conf file, change (temporarily) all METHOD with trust. EG :

    host    all             all             ::1/128                 trust
    

    instead of :

    host    all             all             ::1/128                 md5
    

    You can find where the pg_hba.conf is located by typing in a psql command line:

    SHOW hba_file;
    
    0 讨论(0)
  • 2021-02-01 18:33

    Edit pg_hba.conf to allow you to connect without a password. Then use ALTER USER to reset the password. Then change pg_hba.conf back again.

    For the documentation on pg_hba.conf, see here:

    http://www.postgresql.org/docs/devel/static/auth-pg-hba-conf.html

    0 讨论(0)
  • 2021-02-01 18:34

    Below steps helped me to reset the password-

    1. Go to pg_hba.conf file at path e.g. C:\Program Files\PostgreSQL\10\data and add below line at the end,

      host all postgres 127.0.0.1/32 trust
      
    2. Restart the PostgreSQL service from services control panel (start -> run -> services.msc)

    3. Connect using PgAdmin or any software that you prefer and run query,

      ALTER USER postgres PASSWORD 'postgres'
      
    4. Remove the line that you added in step 1.

    5. Restart PostgreSQL.

    0 讨论(0)
提交回复
热议问题