Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change/reset postgresql user password on windows 7

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 postgresql password on windows 7?

like image 846
Oto Shavadze Avatar asked Sep 03 '13 08:09

Oto Shavadze


People also ask

What do I do if I forgot my postgres password?

If you don't remember your PostgreSQL database password, you can follow the steps below to reset it to a new value: Change the authentication method in the PostgreSQL configuration file pg_hba. conf from md5 to trust and reload the configuration. You should now be able to connect to PostgreSQL with the new password.

What is the default password for postgres Windows?

There is no 'default' PostgreSQL username/password. The credentials supplied in the install process are also used to make these accounts. If you know that username and password you might be able to use the same password to log into PostgreSQL.


2 Answers

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; 
like image 58
Antoine Martin Avatar answered Sep 20 '22 06:09

Antoine Martin


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.

like image 33
Hetal Rachh Avatar answered Sep 23 '22 06:09

Hetal Rachh