How to reset PostgreSQL password

WAS THIS PAGE HELPFUL? Leave Feedback

Overview

Follow the steps below to reset your PostgreSQL root user password.

This process will disrupt access to your system.
During this process, if you received the message No such file or directory, you may need to enter the following command which puts it on the path for environment variables, this is necessary once per shell session:
source /usr/local/groundwork/scripts/setenv.sh
Steps
  1. Stop gwservices:
    /etc/init.d/groundwork stop gwservices
  2. Stop httpd:
    /etc/init.d/groundwork stop apache
  3. Update (not an additional line) the the following file to trust for local connections:
    vi /usr/local/groundwork/postgresql/data/pg_hba.conf

    Example:

    # TYPE  DATABASE        USER            ADDRESS                 METHOD
      host  all             all             127.0.0.1/32            trust
  4. Restart postgres:
    /etc/init.d/groundwork restart postgresql
  5. Open a psql session as the postgres user (you won't be asked for the password under TRUST authentication) to the database:
    psql
  6. Execute the command (leave quotes):
    ALTER USER postgres WITH PASSWORD '<newpassword>';
  7. Leave the session:
    \q
  8. Undo the settings to trust in the file:
    vi /usr/local/groundwork/postgresql/data/pg_hba.conf

    Example:

    # TYPE  DATABASE        USER            ADDRESS                 METHOD
      host  all             all             127.0.0.1/32            md5
  9. Restart gwservices:
    /etc/init.d/groundwork restart gwservices
  10. Restart httpd:
    /etc/init.d/groundwork restart apache
  11. Restart postgres:
    /etc/init.d/groundwork restart postgresql
  12. You should now be able to connect using the new password, you can test by entering psql.

Labels

reset reset Delete
postgresql postgresql Delete
root root Delete
user user Delete
password password Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.