Postgres Default Password

All Postgres default passwords are summed up in great detail:


Default user name Default password
postgresNot required



For window there isn’t a standard password, so no authentication is required You can set create one while the installation process…. Therefore, you must first log in and connect as the postgres user in order to add a password.

$ sudo -u postgres psql

If you were able to connect successfully and you are now seeing the psql prompt, scroll down to the section on changing the password.

$ sudo -u postgres psql template1

Try connecting to the template1 database instead if you got a message saying that the database “postgres” doesn’t exist. If you were successful, move on to changing the password.


What Is PostgreSQL?

PostgreSQL is an object-relational database management system (ORDBMS) based on POSTGRES, Version 4.21 , developed at the University of California at Berkeley Computer Science Department. POSTGRES pioneered many concepts that only became available in some commercial database systems much later.

PostgreSQL is an open-source descendant of this original Berkeley code. It supports a large part of the SQL standard and offers many modern features:

complex queries


foreign keys




updatable views


transactional integrity


multiversion concurrency control





PostgreSQL Default installation

  1. Set a password for postgres:

ALTER ROLE postgres WITH PASSWORD ‘new_password’;

  1. Configure pg­­_hba.conf to use the md5 method and reload
  2. Give ownership of databases to a non applicative role
  3. Revoke rights from the PUBLIC role:



Then one can:

  • Grant rights to applicative roles
  • Setup default privileges to ease the management of rights


How to reset a PostgreSQL password?

  1. Please shut off Toolbox Client and Server before beginning the process.
  2. Open PostgreSQL 9.6 data in C: Program Files.
  3. Copy or backup the conf file.
  4. Launch Notepad and open conf
  5. Locate the several lines that begin with “host” towards the file’s bottom, and add a # to the start of each row, as in “#host all all md5”
  6. At the end of the line Paste these two lines which are as follows:

host all all trust

host all all ::1/128 trust


  1. Save the file and restart the Windows service for PostgreSQL
  • To restart the PostgreSQL Windows service, Go to the Services tab in Task Manager (Ctrl+Shift+Esc) and click “Restart” from the pop-up menu to restart the PostgreSQL service.

postgres default password

  1. From the Start menu, launch the command prompt (write cmd from the Start menu)
    • Use following commands (Press Enter after each command)



cd Program Files

cd PostgreSQL

cd 9.6

cd bin


  • Press enter after using the following commands

psql -U postgres -h localhost


  • Run the command below (ALTER USER….), it is important to finish it with a semicolon. In this example below, the new password is “test,” so type it in after the command by pressing Enter:

ALTER USER postgres with password ‘test’;

postgres default password

  1. Restore the modifications you made in items 5 and 6 or revert to the original pg_hba.conf file. Keep in mind the file’s name and extension.
  2. Restart the PostgreSQL Windows service once again (see Figure above)
  3. Congrats! With the new password established (‘test’), you ought to be able to install the Toolbox database at this point.

Leave a Comment