Databases

Change a PostgreSQL user's password

Set a new password for any PostgreSQL user, including postgres itself.

Fill these in once
  1. Change the password
    Terminal
    psql postgres -c "ALTER USER postgres WITH PASSWORD 'change-me';"

    Prefer not to type it in a command? Open psql and run \password followed by the user name.

  1. Change the passwordNeeds sudo
    Terminal · Ubuntu / Debian
    sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'change-me';"

    Prefer not to type it in a command? Open psql and run \password followed by the user name.

  1. Change the password
    PowerShell
    psql -U postgres -c "ALTER USER postgres WITH PASSWORD 'change-me';"

    Prefer not to type it in a command? Open psql and run \password followed by the user name.