How to change PostgreSQL superuser password

How to change PostgreSQL superuser password

Here is how to change postgresql superuser password on windows 10.

From the terminal:

net user postgres postgres

From the UI:

  • Right Click on My Computer
  • Select Manage
  • Click on local users and groups
  • Then users
  • Right-click on the username
  • Select Set Password

Change PostgreSQL superuser password on Linux

Become the “postgres” system user (either via the root user, sudo or through SSH public key authentication) then connect to the local server using “psql”.

sudo -u postgres psql

You will see postgres=# in reply of command prompt write \password an press enter

Enter your new password here and confirm it.

postgres=# \password
Enter new password:
Enter it again:

Once you have followed these steps your password will be changed successfully.

Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.