skip to Main Content

I can’t access my postgresql datatabase because I forgot my password for PostgresSQL super user. What do I need to do?

I must enter pass when try to uninstall PostgresSQL or open psql database in terminal.

2

Answers


  1. Chosen as BEST ANSWER

    this is solved... thank u so much for all help


  2. First of all switch to PostgreSQL user by running this command on your terminal.

    sudo -i -u postgres
    

    Now you have logged in as postgreSQL user. The next thing to do now is to access postgreSQL prompt. You can do this without using your password.Run this command;

    psql
    

    Now reset your password using this command. Write your new password in the placeholder ‘new-password’.Don’t remove quotes around the new password.

    ALTER USER postgres PASSWORD 'new_password';
    

    Now exit the postgreSQL prompt by using this command

    q
    

    You have to exit from the postgreSQL user shell as well. Use this command;

    exit
    

    At last run this command to restart your postgreSQL service.

    sudo service postgresql restart
    

    Hope it works to solve your issue 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search