Postgresql: password authentication failed for user “postgres”2019 Community Moderator Electionpassword authentication failed for user “postgres”pgAdmin:Password authentication failedHow to start PostgreSQL server on Mac OS X?Getting error: Peer authentication failed for user “postgres”, when trying to get pgsql working with railsHow do I login and authenticate to Postgresql after a fresh install?Postgres password authentication failsFATAL: password authentication failed for user “postgres”PostgreSQL under Lion: What's the password?ERROR: must be superuser to alter superusersWhat is the default password for PostgresPostgreSQL “DESCRIBE TABLE”Show tables in PostgreSQLHow to configure postgresql for the first time?password authentication failed for user “postgres”How to exit from PostgreSQL command line utility: psqlRun a PostgreSQL .sql file using command line argumentsHow to change PostgreSQL user password?Postgres could not connect to serverPostgres password authentication failspsql: FATAL: database “<user>” does not exist

What is this diamond of every day?

Recommendation letter by significant other if you worked with them professionally?

What is Tony Stark injecting into himself in Iron Man 3?

Was it really inappropriate to write a pull request for the company I interviewed with?

What are some noteworthy "mic-drop" moments in math?

What materials can be used to make a humanoid skin warm?

Is it a Cyclops number? "Nobody" knows!

What problems would a superhuman have who's skin is constantly hot?

Windows Server Data Center Edition - Unlimited Virtual Machines

Are all players supposed to be able to see each others' character sheets?

How do electrons receive energy when a body is heated?

How does Ehrenfest's theorem apply to the quantum harmonic oscillator?

What is the generally accepted pronunciation of “topoi”?

Is it possible that a question has only two answers?

Dynamic Linkage of LocatorPane and InputField

School performs periodic password audits. Is my password compromised?

Is a piano played in the same way as a harmonium?

Why is a very small peak with larger m/z not considered to be the molecular ion?

Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?

When a wind turbine does not produce enough electricity how does the power company compensate for the loss?

Source permutation

Does "Until when" sound natural for native speakers?

Would an aboleth's Phantasmal Force lair action be affected by Counterspell, Dispel Magic, and/or Slow?

Rationale to prefer local variables over instance variables?



Postgresql: password authentication failed for user “postgres”



2019 Community Moderator Electionpassword authentication failed for user “postgres”pgAdmin:Password authentication failedHow to start PostgreSQL server on Mac OS X?Getting error: Peer authentication failed for user “postgres”, when trying to get pgsql working with railsHow do I login and authenticate to Postgresql after a fresh install?Postgres password authentication failsFATAL: password authentication failed for user “postgres”PostgreSQL under Lion: What's the password?ERROR: must be superuser to alter superusersWhat is the default password for PostgresPostgreSQL “DESCRIBE TABLE”Show tables in PostgreSQLHow to configure postgresql for the first time?password authentication failed for user “postgres”How to exit from PostgreSQL command line utility: psqlRun a PostgreSQL .sql file using command line argumentsHow to change PostgreSQL user password?Postgres could not connect to serverPostgres password authentication failspsql: FATAL: database “<user>” does not exist










309















I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user "postgres" for both console client and Pgadmin. I have typed user as "postgres" and password "postgres", because it worked before. But now authentication is failed. I did it before a couple of times without this problem. What should I do? And what happens?



psql -U postgres -h localhost -W
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"









share|improve this question



















  • 1





    In my case the connection fails because the password is too complex ...

    – JJD
    Feb 18 '15 at 17:21







  • 2





    Be sure to read all the way down this page. I had to do several things to get this working. First, the ALTER step, then editing my pg_hba.conf file, then restarting postgres.

    – elrobis
    Oct 28 '15 at 19:52











  • Possible duplicate of How do I login and authenticate to Postgresql after a fresh install?

    – Evan Carroll
    Apr 30 '18 at 19:37















309















I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user "postgres" for both console client and Pgadmin. I have typed user as "postgres" and password "postgres", because it worked before. But now authentication is failed. I did it before a couple of times without this problem. What should I do? And what happens?



psql -U postgres -h localhost -W
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"









share|improve this question



















  • 1





    In my case the connection fails because the password is too complex ...

    – JJD
    Feb 18 '15 at 17:21







  • 2





    Be sure to read all the way down this page. I had to do several things to get this working. First, the ALTER step, then editing my pg_hba.conf file, then restarting postgres.

    – elrobis
    Oct 28 '15 at 19:52











  • Possible duplicate of How do I login and authenticate to Postgresql after a fresh install?

    – Evan Carroll
    Apr 30 '18 at 19:37













309












309








309


165






I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user "postgres" for both console client and Pgadmin. I have typed user as "postgres" and password "postgres", because it worked before. But now authentication is failed. I did it before a couple of times without this problem. What should I do? And what happens?



psql -U postgres -h localhost -W
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"









share|improve this question
















I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user "postgres" for both console client and Pgadmin. I have typed user as "postgres" and password "postgres", because it worked before. But now authentication is failed. I did it before a couple of times without this problem. What should I do? And what happens?



psql -U postgres -h localhost -W
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"






postgresql ubuntu pgadmin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 9 '16 at 11:56







I159

















asked Oct 8 '11 at 9:37









I159I159

10.1k2274104




10.1k2274104







  • 1





    In my case the connection fails because the password is too complex ...

    – JJD
    Feb 18 '15 at 17:21







  • 2





    Be sure to read all the way down this page. I had to do several things to get this working. First, the ALTER step, then editing my pg_hba.conf file, then restarting postgres.

    – elrobis
    Oct 28 '15 at 19:52











  • Possible duplicate of How do I login and authenticate to Postgresql after a fresh install?

    – Evan Carroll
    Apr 30 '18 at 19:37












  • 1





    In my case the connection fails because the password is too complex ...

    – JJD
    Feb 18 '15 at 17:21







  • 2





    Be sure to read all the way down this page. I had to do several things to get this working. First, the ALTER step, then editing my pg_hba.conf file, then restarting postgres.

    – elrobis
    Oct 28 '15 at 19:52











  • Possible duplicate of How do I login and authenticate to Postgresql after a fresh install?

    – Evan Carroll
    Apr 30 '18 at 19:37







1




1





In my case the connection fails because the password is too complex ...

– JJD
Feb 18 '15 at 17:21






In my case the connection fails because the password is too complex ...

– JJD
Feb 18 '15 at 17:21





2




2





Be sure to read all the way down this page. I had to do several things to get this working. First, the ALTER step, then editing my pg_hba.conf file, then restarting postgres.

– elrobis
Oct 28 '15 at 19:52





Be sure to read all the way down this page. I had to do several things to get this working. First, the ALTER step, then editing my pg_hba.conf file, then restarting postgres.

– elrobis
Oct 28 '15 at 19:52













Possible duplicate of How do I login and authenticate to Postgresql after a fresh install?

– Evan Carroll
Apr 30 '18 at 19:37





Possible duplicate of How do I login and authenticate to Postgresql after a fresh install?

– Evan Carroll
Apr 30 '18 at 19:37












12 Answers
12






active

oldest

votes


















579














If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.



Assuming, that you have root access on the box you can do:



sudo -u postgres psql


If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server :-) In this case simply add template1 to the command:



sudo -u postgres psql template1


If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:



local all postgres ident


For newer versions of PostgreSQL ident actually might be peer. That's OK also.



Inside the psql shell you can give the DB user postgres a password:



ALTER USER postgres PASSWORD 'newPassword';


You can leave the psql shell by typing CtrlD or with the command q.



Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. :-)






share|improve this answer

























  • That's better, thanks you! psql is works. But still have problems with pgadmin3 - it's asked me a password for my system root user. (strange for me) pg_hba.conf just like you say.

    – I159
    Oct 8 '11 at 16:41












  • I'd add to then exit the console using 'q'. Took me a while to find that :)

    – hakunin
    Sep 11 '12 at 7:34












  • Note, that pg_hba.conf must have the postgres user set to ident in order for the first steps to work. If you already set it to md5 or something else, you won't be able to auto-login.

    – Cerin
    Sep 28 '13 at 23:33






  • 55





    Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line.

    – itsols
    Nov 1 '13 at 16:18






  • 1





    @itsols You said: "Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line"... You just ended a four hour ordeal!! I feel sooooo stupid and grateful right now. :-D

    – frozenjim
    Jan 24 '18 at 21:16



















118














The response of staff is correct, but if you want to further automate can do:



$ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"



Done! You saved User = postgres and password = postgres.



If you do not have a password for the User postgres ubuntu do:



$ sudo passwd postgres






share|improve this answer

























  • This commands fails since you are not passing the port.

    – Luís de Sousa
    Jun 1 '16 at 10:31


















33














This was frustrating, most of the above answers are correct but they fail to mention you have to restart the database service before the changes in the pg_hba.conf file will take affect.



so if you make the changes as mentioned above:



local all postgres ident


then restart as root ( on centos its something like service service postgresql-9.2 restart )
now you should be able to access the db as the user postgres



$psql
psql (9.2.4)
Type "help" for help.

postgres=#


Hope this adds info for new postgres users






share|improve this answer




















  • 19





    On ubuntu type: sudo service postgresql restart

    – Ann Kilzer
    Dec 16 '13 at 17:58







  • 3





    for RHEL7 use sudo systemctl restart postgresql.service

    – Spechal
    Aug 6 '14 at 15:23











  • What about on mac?

    – AustinT
    Apr 20 '16 at 1:55











  • For mac, checkout this question on SO stackoverflow.com/questions/7975556/…

    – Rohith Nandakumar
    Aug 1 '16 at 10:26


















14














Edit the pg_hba.conf file, e.g. with sudo emacs /etc/postgresql/9.3/main/pg_hba.conf



Change all authentication methods to trust. Change Unix Password for "postgres" user. Restart Server. Login with psql -h localhost -U postgres and use the just set Unix password. If it works you can re-set the pg_hba.conf file to the default values.






share|improve this answer


















  • 1





    If you get completely stuck, this is the only guaranteed method. Change all methods to trust, restart db, then as root: sudo su - postgres, next set/fix/unset password for postgres db (and in the shell, if necessary), then restore to secure md5 or ident methods and restart again so values stick. By the way, on Cent/RedHat 9.4 the file is located at: /var/lib/pgsql/9.4/data/pg_hba.conf

    – PapaK
    Nov 4 '15 at 20:24



















11














If you are trying to login postgres shell as postgres user, then you can use following commands.



switch to postgres user



# su - postgres


login to psql



# psql


Hope that helps






share|improve this answer




















  • 3





    su - postgres asks for a password on posgresql 9.5 on Ubuntu 16.04

    – Prashanth Chandra
    Jun 8 '17 at 10:38







  • 2





    su - postgres is the command that the official fedora documentation suggests, but I too get a password prompt. To get round that I followed this postgres forum email that uses the same command as the accepted answer here: sudo -u postgres psql. Don't forget to init and start the database server.

    – icc97
    Dec 17 '17 at 10:44


















10














Try to not use the -W parameter and leave the password in blank. Sometimes the user is created with no-password.



If that doesn't work reset the password. There are several ways to do it, but this works on many systems:



$ su root
$ su postgres
$ psql -h localhost
> ALTER USER postgres with password 'YourNewPassword';





share|improve this answer






























    8














    For those who are using it first time and have no information regarding what the password is they can follow the below steps(assuming you are on ubuntu):




    1. Open the file pg_hba.conf in /etc/postgresql/9.x/main



       sudo vi pg_hba.conf 


      2.edit the below line



       local all postgres peer


      to



       local all postgres trust



    2. Restart the server



       sudo service postgresql restart


    3. Finally you can login without need of a password as shown in the figureFinally you can login without need of a password as shown in the figure


    Ref here for more info






    share|improve this answer























    • Worked for me, thank you

      – Richard Peck
      Mar 2 at 20:25


















    2














    As a rule of thumb: YOU SHOULD NEVER EVER SET A PASSWORD FOR THE POSTGRES USER.



    If you need a superuser access from pgAdmin, make another superuser. That way, if the credentials for that superuser is compromised, you can always ssh into the actual database host and manually delete the superuser using



    sudo -u postgres -c "DROP ROLE superuser;"





    share|improve this answer























    • What's the reason for this rule of thumb?

      – Gershom Maes
      Mar 21 '18 at 20:06











    • So that you can never have all your superusers conpromised.

      – ardilgulez
      Mar 22 '18 at 10:34











    • How can setting a password for postgres lead to having all superusers compromised?

      – Gershom Maes
      Mar 22 '18 at 17:11






    • 2





      setting password doesn't lead to having all superusers compromised but not setting the password will guarantee that you'll never have all superusers compromised. the reason is: when you don't set the password, any password login attempt to postgres user will be denied whereas you can still use it yourself by trust.

      – ardilgulez
      Mar 24 '18 at 0:39


















    0














    I just wanted to add that you should also check if your password is expired.



    See Postgres password authentication fails for details.






    share|improve this answer




















    • 1





      Please add some details and a summary of what that link provides in case in the future the link no longer exists. Otherwise this is likely to be flagged as a low-quality/link only answer.

      – Tanner
      Sep 2 '14 at 15:24






    • 1





      Thanks. I think my answer is clear enough.

      – Jörg
      Sep 2 '14 at 15:28











    • I'd have a read of this: meta.stackexchange.com/questions/8231/…

      – Tanner
      Sep 2 '14 at 15:34


















    0














    Here are some combinations which I tried to login:



    # login via user foo
    psql -Ufoo -h localhost

    sudo -u postgres psql postgres

    # user foo login to postgres db
    psql -Ufoo -h localhost -d postgres





    share|improve this answer






























      0














      i had a similar problem.
      Ubuntu was left me log in in console with any password for superuser.
      Except when i connected with -h localhost in psql line command.



      I Observed too that "localhost:8080/MyJSPSiteLogIn" - showed: Fatal: autentication error with user "user".



      pg_hba.conf was ok.



      I noted had two versions of postgres running in the same service.



      Solved - uninstalling inutil version.






      share|improve this answer






























        -1














        I hope this will help you short of time.
        You can change the password of postgres sql by using bellow command.



        Command



        sudo -u postgres psql



        And next you can update the password



        Command



        Alter user postgres password 'YOUR_NEW_PASSWORD';






        share|improve this answer


















        • 1





          Your answer just contains information, that has already been added: stackoverflow.com/a/7696398/8283469

          – L. Guthardt
          Jul 2 '18 at 11:21










        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7695962%2fpostgresql-password-authentication-failed-for-user-postgres%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        12 Answers
        12






        active

        oldest

        votes








        12 Answers
        12






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        579














        If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.



        Assuming, that you have root access on the box you can do:



        sudo -u postgres psql


        If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server :-) In this case simply add template1 to the command:



        sudo -u postgres psql template1


        If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:



        local all postgres ident


        For newer versions of PostgreSQL ident actually might be peer. That's OK also.



        Inside the psql shell you can give the DB user postgres a password:



        ALTER USER postgres PASSWORD 'newPassword';


        You can leave the psql shell by typing CtrlD or with the command q.



        Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. :-)






        share|improve this answer

























        • That's better, thanks you! psql is works. But still have problems with pgadmin3 - it's asked me a password for my system root user. (strange for me) pg_hba.conf just like you say.

          – I159
          Oct 8 '11 at 16:41












        • I'd add to then exit the console using 'q'. Took me a while to find that :)

          – hakunin
          Sep 11 '12 at 7:34












        • Note, that pg_hba.conf must have the postgres user set to ident in order for the first steps to work. If you already set it to md5 or something else, you won't be able to auto-login.

          – Cerin
          Sep 28 '13 at 23:33






        • 55





          Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line.

          – itsols
          Nov 1 '13 at 16:18






        • 1





          @itsols You said: "Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line"... You just ended a four hour ordeal!! I feel sooooo stupid and grateful right now. :-D

          – frozenjim
          Jan 24 '18 at 21:16
















        579














        If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.



        Assuming, that you have root access on the box you can do:



        sudo -u postgres psql


        If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server :-) In this case simply add template1 to the command:



        sudo -u postgres psql template1


        If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:



        local all postgres ident


        For newer versions of PostgreSQL ident actually might be peer. That's OK also.



        Inside the psql shell you can give the DB user postgres a password:



        ALTER USER postgres PASSWORD 'newPassword';


        You can leave the psql shell by typing CtrlD or with the command q.



        Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. :-)






        share|improve this answer

























        • That's better, thanks you! psql is works. But still have problems with pgadmin3 - it's asked me a password for my system root user. (strange for me) pg_hba.conf just like you say.

          – I159
          Oct 8 '11 at 16:41












        • I'd add to then exit the console using 'q'. Took me a while to find that :)

          – hakunin
          Sep 11 '12 at 7:34












        • Note, that pg_hba.conf must have the postgres user set to ident in order for the first steps to work. If you already set it to md5 or something else, you won't be able to auto-login.

          – Cerin
          Sep 28 '13 at 23:33






        • 55





          Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line.

          – itsols
          Nov 1 '13 at 16:18






        • 1





          @itsols You said: "Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line"... You just ended a four hour ordeal!! I feel sooooo stupid and grateful right now. :-D

          – frozenjim
          Jan 24 '18 at 21:16














        579












        579








        579







        If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.



        Assuming, that you have root access on the box you can do:



        sudo -u postgres psql


        If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server :-) In this case simply add template1 to the command:



        sudo -u postgres psql template1


        If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:



        local all postgres ident


        For newer versions of PostgreSQL ident actually might be peer. That's OK also.



        Inside the psql shell you can give the DB user postgres a password:



        ALTER USER postgres PASSWORD 'newPassword';


        You can leave the psql shell by typing CtrlD or with the command q.



        Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. :-)






        share|improve this answer















        If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.



        Assuming, that you have root access on the box you can do:



        sudo -u postgres psql


        If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server :-) In this case simply add template1 to the command:



        sudo -u postgres psql template1


        If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:



        local all postgres ident


        For newer versions of PostgreSQL ident actually might be peer. That's OK also.



        Inside the psql shell you can give the DB user postgres a password:



        ALTER USER postgres PASSWORD 'newPassword';


        You can leave the psql shell by typing CtrlD or with the command q.



        Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. :-)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 14 '16 at 5:07









        Brian

        14.5k62443




        14.5k62443










        answered Oct 8 '11 at 11:11









        A.H.A.H.

        46.2k117098




        46.2k117098












        • That's better, thanks you! psql is works. But still have problems with pgadmin3 - it's asked me a password for my system root user. (strange for me) pg_hba.conf just like you say.

          – I159
          Oct 8 '11 at 16:41












        • I'd add to then exit the console using 'q'. Took me a while to find that :)

          – hakunin
          Sep 11 '12 at 7:34












        • Note, that pg_hba.conf must have the postgres user set to ident in order for the first steps to work. If you already set it to md5 or something else, you won't be able to auto-login.

          – Cerin
          Sep 28 '13 at 23:33






        • 55





          Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line.

          – itsols
          Nov 1 '13 at 16:18






        • 1





          @itsols You said: "Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line"... You just ended a four hour ordeal!! I feel sooooo stupid and grateful right now. :-D

          – frozenjim
          Jan 24 '18 at 21:16


















        • That's better, thanks you! psql is works. But still have problems with pgadmin3 - it's asked me a password for my system root user. (strange for me) pg_hba.conf just like you say.

          – I159
          Oct 8 '11 at 16:41












        • I'd add to then exit the console using 'q'. Took me a while to find that :)

          – hakunin
          Sep 11 '12 at 7:34












        • Note, that pg_hba.conf must have the postgres user set to ident in order for the first steps to work. If you already set it to md5 or something else, you won't be able to auto-login.

          – Cerin
          Sep 28 '13 at 23:33






        • 55





          Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line.

          – itsols
          Nov 1 '13 at 16:18






        • 1





          @itsols You said: "Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line"... You just ended a four hour ordeal!! I feel sooooo stupid and grateful right now. :-D

          – frozenjim
          Jan 24 '18 at 21:16

















        That's better, thanks you! psql is works. But still have problems with pgadmin3 - it's asked me a password for my system root user. (strange for me) pg_hba.conf just like you say.

        – I159
        Oct 8 '11 at 16:41






        That's better, thanks you! psql is works. But still have problems with pgadmin3 - it's asked me a password for my system root user. (strange for me) pg_hba.conf just like you say.

        – I159
        Oct 8 '11 at 16:41














        I'd add to then exit the console using 'q'. Took me a while to find that :)

        – hakunin
        Sep 11 '12 at 7:34






        I'd add to then exit the console using 'q'. Took me a while to find that :)

        – hakunin
        Sep 11 '12 at 7:34














        Note, that pg_hba.conf must have the postgres user set to ident in order for the first steps to work. If you already set it to md5 or something else, you won't be able to auto-login.

        – Cerin
        Sep 28 '13 at 23:33





        Note, that pg_hba.conf must have the postgres user set to ident in order for the first steps to work. If you already set it to md5 or something else, you won't be able to auto-login.

        – Cerin
        Sep 28 '13 at 23:33




        55




        55





        Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line.

        – itsols
        Nov 1 '13 at 16:18





        Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line.

        – itsols
        Nov 1 '13 at 16:18




        1




        1





        @itsols You said: "Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line"... You just ended a four hour ordeal!! I feel sooooo stupid and grateful right now. :-D

        – frozenjim
        Jan 24 '18 at 21:16






        @itsols You said: "Very nice one. To other new users, DON'T FORGET THE SEMICOLON at the end of the ALTER USER line"... You just ended a four hour ordeal!! I feel sooooo stupid and grateful right now. :-D

        – frozenjim
        Jan 24 '18 at 21:16














        118














        The response of staff is correct, but if you want to further automate can do:



        $ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"



        Done! You saved User = postgres and password = postgres.



        If you do not have a password for the User postgres ubuntu do:



        $ sudo passwd postgres






        share|improve this answer

























        • This commands fails since you are not passing the port.

          – Luís de Sousa
          Jun 1 '16 at 10:31















        118














        The response of staff is correct, but if you want to further automate can do:



        $ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"



        Done! You saved User = postgres and password = postgres.



        If you do not have a password for the User postgres ubuntu do:



        $ sudo passwd postgres






        share|improve this answer

























        • This commands fails since you are not passing the port.

          – Luís de Sousa
          Jun 1 '16 at 10:31













        118












        118








        118







        The response of staff is correct, but if you want to further automate can do:



        $ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"



        Done! You saved User = postgres and password = postgres.



        If you do not have a password for the User postgres ubuntu do:



        $ sudo passwd postgres






        share|improve this answer















        The response of staff is correct, but if you want to further automate can do:



        $ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"



        Done! You saved User = postgres and password = postgres.



        If you do not have a password for the User postgres ubuntu do:



        $ sudo passwd postgres







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 24 '12 at 19:33

























        answered Dec 10 '12 at 7:19









        DiegoDiego

        1,5311105




        1,5311105












        • This commands fails since you are not passing the port.

          – Luís de Sousa
          Jun 1 '16 at 10:31

















        • This commands fails since you are not passing the port.

          – Luís de Sousa
          Jun 1 '16 at 10:31
















        This commands fails since you are not passing the port.

        – Luís de Sousa
        Jun 1 '16 at 10:31





        This commands fails since you are not passing the port.

        – Luís de Sousa
        Jun 1 '16 at 10:31











        33














        This was frustrating, most of the above answers are correct but they fail to mention you have to restart the database service before the changes in the pg_hba.conf file will take affect.



        so if you make the changes as mentioned above:



        local all postgres ident


        then restart as root ( on centos its something like service service postgresql-9.2 restart )
        now you should be able to access the db as the user postgres



        $psql
        psql (9.2.4)
        Type "help" for help.

        postgres=#


        Hope this adds info for new postgres users






        share|improve this answer




















        • 19





          On ubuntu type: sudo service postgresql restart

          – Ann Kilzer
          Dec 16 '13 at 17:58







        • 3





          for RHEL7 use sudo systemctl restart postgresql.service

          – Spechal
          Aug 6 '14 at 15:23











        • What about on mac?

          – AustinT
          Apr 20 '16 at 1:55











        • For mac, checkout this question on SO stackoverflow.com/questions/7975556/…

          – Rohith Nandakumar
          Aug 1 '16 at 10:26















        33














        This was frustrating, most of the above answers are correct but they fail to mention you have to restart the database service before the changes in the pg_hba.conf file will take affect.



        so if you make the changes as mentioned above:



        local all postgres ident


        then restart as root ( on centos its something like service service postgresql-9.2 restart )
        now you should be able to access the db as the user postgres



        $psql
        psql (9.2.4)
        Type "help" for help.

        postgres=#


        Hope this adds info for new postgres users






        share|improve this answer




















        • 19





          On ubuntu type: sudo service postgresql restart

          – Ann Kilzer
          Dec 16 '13 at 17:58







        • 3





          for RHEL7 use sudo systemctl restart postgresql.service

          – Spechal
          Aug 6 '14 at 15:23











        • What about on mac?

          – AustinT
          Apr 20 '16 at 1:55











        • For mac, checkout this question on SO stackoverflow.com/questions/7975556/…

          – Rohith Nandakumar
          Aug 1 '16 at 10:26













        33












        33








        33







        This was frustrating, most of the above answers are correct but they fail to mention you have to restart the database service before the changes in the pg_hba.conf file will take affect.



        so if you make the changes as mentioned above:



        local all postgres ident


        then restart as root ( on centos its something like service service postgresql-9.2 restart )
        now you should be able to access the db as the user postgres



        $psql
        psql (9.2.4)
        Type "help" for help.

        postgres=#


        Hope this adds info for new postgres users






        share|improve this answer















        This was frustrating, most of the above answers are correct but they fail to mention you have to restart the database service before the changes in the pg_hba.conf file will take affect.



        so if you make the changes as mentioned above:



        local all postgres ident


        then restart as root ( on centos its something like service service postgresql-9.2 restart )
        now you should be able to access the db as the user postgres



        $psql
        psql (9.2.4)
        Type "help" for help.

        postgres=#


        Hope this adds info for new postgres users







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 6 at 14:25









        Andronicus

        4,16421429




        4,16421429










        answered Aug 5 '13 at 18:17









        Miguel PereiraMiguel Pereira

        1,2961112




        1,2961112







        • 19





          On ubuntu type: sudo service postgresql restart

          – Ann Kilzer
          Dec 16 '13 at 17:58







        • 3





          for RHEL7 use sudo systemctl restart postgresql.service

          – Spechal
          Aug 6 '14 at 15:23











        • What about on mac?

          – AustinT
          Apr 20 '16 at 1:55











        • For mac, checkout this question on SO stackoverflow.com/questions/7975556/…

          – Rohith Nandakumar
          Aug 1 '16 at 10:26












        • 19





          On ubuntu type: sudo service postgresql restart

          – Ann Kilzer
          Dec 16 '13 at 17:58







        • 3





          for RHEL7 use sudo systemctl restart postgresql.service

          – Spechal
          Aug 6 '14 at 15:23











        • What about on mac?

          – AustinT
          Apr 20 '16 at 1:55











        • For mac, checkout this question on SO stackoverflow.com/questions/7975556/…

          – Rohith Nandakumar
          Aug 1 '16 at 10:26







        19




        19





        On ubuntu type: sudo service postgresql restart

        – Ann Kilzer
        Dec 16 '13 at 17:58






        On ubuntu type: sudo service postgresql restart

        – Ann Kilzer
        Dec 16 '13 at 17:58





        3




        3





        for RHEL7 use sudo systemctl restart postgresql.service

        – Spechal
        Aug 6 '14 at 15:23





        for RHEL7 use sudo systemctl restart postgresql.service

        – Spechal
        Aug 6 '14 at 15:23













        What about on mac?

        – AustinT
        Apr 20 '16 at 1:55





        What about on mac?

        – AustinT
        Apr 20 '16 at 1:55













        For mac, checkout this question on SO stackoverflow.com/questions/7975556/…

        – Rohith Nandakumar
        Aug 1 '16 at 10:26





        For mac, checkout this question on SO stackoverflow.com/questions/7975556/…

        – Rohith Nandakumar
        Aug 1 '16 at 10:26











        14














        Edit the pg_hba.conf file, e.g. with sudo emacs /etc/postgresql/9.3/main/pg_hba.conf



        Change all authentication methods to trust. Change Unix Password for "postgres" user. Restart Server. Login with psql -h localhost -U postgres and use the just set Unix password. If it works you can re-set the pg_hba.conf file to the default values.






        share|improve this answer


















        • 1





          If you get completely stuck, this is the only guaranteed method. Change all methods to trust, restart db, then as root: sudo su - postgres, next set/fix/unset password for postgres db (and in the shell, if necessary), then restore to secure md5 or ident methods and restart again so values stick. By the way, on Cent/RedHat 9.4 the file is located at: /var/lib/pgsql/9.4/data/pg_hba.conf

          – PapaK
          Nov 4 '15 at 20:24
















        14














        Edit the pg_hba.conf file, e.g. with sudo emacs /etc/postgresql/9.3/main/pg_hba.conf



        Change all authentication methods to trust. Change Unix Password for "postgres" user. Restart Server. Login with psql -h localhost -U postgres and use the just set Unix password. If it works you can re-set the pg_hba.conf file to the default values.






        share|improve this answer


















        • 1





          If you get completely stuck, this is the only guaranteed method. Change all methods to trust, restart db, then as root: sudo su - postgres, next set/fix/unset password for postgres db (and in the shell, if necessary), then restore to secure md5 or ident methods and restart again so values stick. By the way, on Cent/RedHat 9.4 the file is located at: /var/lib/pgsql/9.4/data/pg_hba.conf

          – PapaK
          Nov 4 '15 at 20:24














        14












        14








        14







        Edit the pg_hba.conf file, e.g. with sudo emacs /etc/postgresql/9.3/main/pg_hba.conf



        Change all authentication methods to trust. Change Unix Password for "postgres" user. Restart Server. Login with psql -h localhost -U postgres and use the just set Unix password. If it works you can re-set the pg_hba.conf file to the default values.






        share|improve this answer













        Edit the pg_hba.conf file, e.g. with sudo emacs /etc/postgresql/9.3/main/pg_hba.conf



        Change all authentication methods to trust. Change Unix Password for "postgres" user. Restart Server. Login with psql -h localhost -U postgres and use the just set Unix password. If it works you can re-set the pg_hba.conf file to the default values.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 10 '14 at 15:43









        nottinhillnottinhill

        7,365646102




        7,365646102







        • 1





          If you get completely stuck, this is the only guaranteed method. Change all methods to trust, restart db, then as root: sudo su - postgres, next set/fix/unset password for postgres db (and in the shell, if necessary), then restore to secure md5 or ident methods and restart again so values stick. By the way, on Cent/RedHat 9.4 the file is located at: /var/lib/pgsql/9.4/data/pg_hba.conf

          – PapaK
          Nov 4 '15 at 20:24













        • 1





          If you get completely stuck, this is the only guaranteed method. Change all methods to trust, restart db, then as root: sudo su - postgres, next set/fix/unset password for postgres db (and in the shell, if necessary), then restore to secure md5 or ident methods and restart again so values stick. By the way, on Cent/RedHat 9.4 the file is located at: /var/lib/pgsql/9.4/data/pg_hba.conf

          – PapaK
          Nov 4 '15 at 20:24








        1




        1





        If you get completely stuck, this is the only guaranteed method. Change all methods to trust, restart db, then as root: sudo su - postgres, next set/fix/unset password for postgres db (and in the shell, if necessary), then restore to secure md5 or ident methods and restart again so values stick. By the way, on Cent/RedHat 9.4 the file is located at: /var/lib/pgsql/9.4/data/pg_hba.conf

        – PapaK
        Nov 4 '15 at 20:24






        If you get completely stuck, this is the only guaranteed method. Change all methods to trust, restart db, then as root: sudo su - postgres, next set/fix/unset password for postgres db (and in the shell, if necessary), then restore to secure md5 or ident methods and restart again so values stick. By the way, on Cent/RedHat 9.4 the file is located at: /var/lib/pgsql/9.4/data/pg_hba.conf

        – PapaK
        Nov 4 '15 at 20:24












        11














        If you are trying to login postgres shell as postgres user, then you can use following commands.



        switch to postgres user



        # su - postgres


        login to psql



        # psql


        Hope that helps






        share|improve this answer




















        • 3





          su - postgres asks for a password on posgresql 9.5 on Ubuntu 16.04

          – Prashanth Chandra
          Jun 8 '17 at 10:38







        • 2





          su - postgres is the command that the official fedora documentation suggests, but I too get a password prompt. To get round that I followed this postgres forum email that uses the same command as the accepted answer here: sudo -u postgres psql. Don't forget to init and start the database server.

          – icc97
          Dec 17 '17 at 10:44















        11














        If you are trying to login postgres shell as postgres user, then you can use following commands.



        switch to postgres user



        # su - postgres


        login to psql



        # psql


        Hope that helps






        share|improve this answer




















        • 3





          su - postgres asks for a password on posgresql 9.5 on Ubuntu 16.04

          – Prashanth Chandra
          Jun 8 '17 at 10:38







        • 2





          su - postgres is the command that the official fedora documentation suggests, but I too get a password prompt. To get round that I followed this postgres forum email that uses the same command as the accepted answer here: sudo -u postgres psql. Don't forget to init and start the database server.

          – icc97
          Dec 17 '17 at 10:44













        11












        11








        11







        If you are trying to login postgres shell as postgres user, then you can use following commands.



        switch to postgres user



        # su - postgres


        login to psql



        # psql


        Hope that helps






        share|improve this answer















        If you are trying to login postgres shell as postgres user, then you can use following commands.



        switch to postgres user



        # su - postgres


        login to psql



        # psql


        Hope that helps







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 16 '15 at 13:32









        Iharob Al Asimi

        48.6k54380




        48.6k54380










        answered Jun 13 '13 at 9:05









        geekgugigeekgugi

        3111418




        3111418







        • 3





          su - postgres asks for a password on posgresql 9.5 on Ubuntu 16.04

          – Prashanth Chandra
          Jun 8 '17 at 10:38







        • 2





          su - postgres is the command that the official fedora documentation suggests, but I too get a password prompt. To get round that I followed this postgres forum email that uses the same command as the accepted answer here: sudo -u postgres psql. Don't forget to init and start the database server.

          – icc97
          Dec 17 '17 at 10:44












        • 3





          su - postgres asks for a password on posgresql 9.5 on Ubuntu 16.04

          – Prashanth Chandra
          Jun 8 '17 at 10:38







        • 2





          su - postgres is the command that the official fedora documentation suggests, but I too get a password prompt. To get round that I followed this postgres forum email that uses the same command as the accepted answer here: sudo -u postgres psql. Don't forget to init and start the database server.

          – icc97
          Dec 17 '17 at 10:44







        3




        3





        su - postgres asks for a password on posgresql 9.5 on Ubuntu 16.04

        – Prashanth Chandra
        Jun 8 '17 at 10:38






        su - postgres asks for a password on posgresql 9.5 on Ubuntu 16.04

        – Prashanth Chandra
        Jun 8 '17 at 10:38





        2




        2





        su - postgres is the command that the official fedora documentation suggests, but I too get a password prompt. To get round that I followed this postgres forum email that uses the same command as the accepted answer here: sudo -u postgres psql. Don't forget to init and start the database server.

        – icc97
        Dec 17 '17 at 10:44





        su - postgres is the command that the official fedora documentation suggests, but I too get a password prompt. To get round that I followed this postgres forum email that uses the same command as the accepted answer here: sudo -u postgres psql. Don't forget to init and start the database server.

        – icc97
        Dec 17 '17 at 10:44











        10














        Try to not use the -W parameter and leave the password in blank. Sometimes the user is created with no-password.



        If that doesn't work reset the password. There are several ways to do it, but this works on many systems:



        $ su root
        $ su postgres
        $ psql -h localhost
        > ALTER USER postgres with password 'YourNewPassword';





        share|improve this answer



























          10














          Try to not use the -W parameter and leave the password in blank. Sometimes the user is created with no-password.



          If that doesn't work reset the password. There are several ways to do it, but this works on many systems:



          $ su root
          $ su postgres
          $ psql -h localhost
          > ALTER USER postgres with password 'YourNewPassword';





          share|improve this answer

























            10












            10








            10







            Try to not use the -W parameter and leave the password in blank. Sometimes the user is created with no-password.



            If that doesn't work reset the password. There are several ways to do it, but this works on many systems:



            $ su root
            $ su postgres
            $ psql -h localhost
            > ALTER USER postgres with password 'YourNewPassword';





            share|improve this answer













            Try to not use the -W parameter and leave the password in blank. Sometimes the user is created with no-password.



            If that doesn't work reset the password. There are several ways to do it, but this works on many systems:



            $ su root
            $ su postgres
            $ psql -h localhost
            > ALTER USER postgres with password 'YourNewPassword';






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 8 '11 at 10:03









            Francisco PugaFrancisco Puga

            15.5k33348




            15.5k33348





















                8














                For those who are using it first time and have no information regarding what the password is they can follow the below steps(assuming you are on ubuntu):




                1. Open the file pg_hba.conf in /etc/postgresql/9.x/main



                   sudo vi pg_hba.conf 


                  2.edit the below line



                   local all postgres peer


                  to



                   local all postgres trust



                2. Restart the server



                   sudo service postgresql restart


                3. Finally you can login without need of a password as shown in the figureFinally you can login without need of a password as shown in the figure


                Ref here for more info






                share|improve this answer























                • Worked for me, thank you

                  – Richard Peck
                  Mar 2 at 20:25















                8














                For those who are using it first time and have no information regarding what the password is they can follow the below steps(assuming you are on ubuntu):




                1. Open the file pg_hba.conf in /etc/postgresql/9.x/main



                   sudo vi pg_hba.conf 


                  2.edit the below line



                   local all postgres peer


                  to



                   local all postgres trust



                2. Restart the server



                   sudo service postgresql restart


                3. Finally you can login without need of a password as shown in the figureFinally you can login without need of a password as shown in the figure


                Ref here for more info






                share|improve this answer























                • Worked for me, thank you

                  – Richard Peck
                  Mar 2 at 20:25













                8












                8








                8







                For those who are using it first time and have no information regarding what the password is they can follow the below steps(assuming you are on ubuntu):




                1. Open the file pg_hba.conf in /etc/postgresql/9.x/main



                   sudo vi pg_hba.conf 


                  2.edit the below line



                   local all postgres peer


                  to



                   local all postgres trust



                2. Restart the server



                   sudo service postgresql restart


                3. Finally you can login without need of a password as shown in the figureFinally you can login without need of a password as shown in the figure


                Ref here for more info






                share|improve this answer













                For those who are using it first time and have no information regarding what the password is they can follow the below steps(assuming you are on ubuntu):




                1. Open the file pg_hba.conf in /etc/postgresql/9.x/main



                   sudo vi pg_hba.conf 


                  2.edit the below line



                   local all postgres peer


                  to



                   local all postgres trust



                2. Restart the server



                   sudo service postgresql restart


                3. Finally you can login without need of a password as shown in the figureFinally you can login without need of a password as shown in the figure


                Ref here for more info







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 16 '18 at 8:21









                Jose KjJose Kj

                1,1821422




                1,1821422












                • Worked for me, thank you

                  – Richard Peck
                  Mar 2 at 20:25

















                • Worked for me, thank you

                  – Richard Peck
                  Mar 2 at 20:25
















                Worked for me, thank you

                – Richard Peck
                Mar 2 at 20:25





                Worked for me, thank you

                – Richard Peck
                Mar 2 at 20:25











                2














                As a rule of thumb: YOU SHOULD NEVER EVER SET A PASSWORD FOR THE POSTGRES USER.



                If you need a superuser access from pgAdmin, make another superuser. That way, if the credentials for that superuser is compromised, you can always ssh into the actual database host and manually delete the superuser using



                sudo -u postgres -c "DROP ROLE superuser;"





                share|improve this answer























                • What's the reason for this rule of thumb?

                  – Gershom Maes
                  Mar 21 '18 at 20:06











                • So that you can never have all your superusers conpromised.

                  – ardilgulez
                  Mar 22 '18 at 10:34











                • How can setting a password for postgres lead to having all superusers compromised?

                  – Gershom Maes
                  Mar 22 '18 at 17:11






                • 2





                  setting password doesn't lead to having all superusers compromised but not setting the password will guarantee that you'll never have all superusers compromised. the reason is: when you don't set the password, any password login attempt to postgres user will be denied whereas you can still use it yourself by trust.

                  – ardilgulez
                  Mar 24 '18 at 0:39















                2














                As a rule of thumb: YOU SHOULD NEVER EVER SET A PASSWORD FOR THE POSTGRES USER.



                If you need a superuser access from pgAdmin, make another superuser. That way, if the credentials for that superuser is compromised, you can always ssh into the actual database host and manually delete the superuser using



                sudo -u postgres -c "DROP ROLE superuser;"





                share|improve this answer























                • What's the reason for this rule of thumb?

                  – Gershom Maes
                  Mar 21 '18 at 20:06











                • So that you can never have all your superusers conpromised.

                  – ardilgulez
                  Mar 22 '18 at 10:34











                • How can setting a password for postgres lead to having all superusers compromised?

                  – Gershom Maes
                  Mar 22 '18 at 17:11






                • 2





                  setting password doesn't lead to having all superusers compromised but not setting the password will guarantee that you'll never have all superusers compromised. the reason is: when you don't set the password, any password login attempt to postgres user will be denied whereas you can still use it yourself by trust.

                  – ardilgulez
                  Mar 24 '18 at 0:39













                2












                2








                2







                As a rule of thumb: YOU SHOULD NEVER EVER SET A PASSWORD FOR THE POSTGRES USER.



                If you need a superuser access from pgAdmin, make another superuser. That way, if the credentials for that superuser is compromised, you can always ssh into the actual database host and manually delete the superuser using



                sudo -u postgres -c "DROP ROLE superuser;"





                share|improve this answer













                As a rule of thumb: YOU SHOULD NEVER EVER SET A PASSWORD FOR THE POSTGRES USER.



                If you need a superuser access from pgAdmin, make another superuser. That way, if the credentials for that superuser is compromised, you can always ssh into the actual database host and manually delete the superuser using



                sudo -u postgres -c "DROP ROLE superuser;"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 20 '16 at 10:27









                ardilgulezardilgulez

                1,155914




                1,155914












                • What's the reason for this rule of thumb?

                  – Gershom Maes
                  Mar 21 '18 at 20:06











                • So that you can never have all your superusers conpromised.

                  – ardilgulez
                  Mar 22 '18 at 10:34











                • How can setting a password for postgres lead to having all superusers compromised?

                  – Gershom Maes
                  Mar 22 '18 at 17:11






                • 2





                  setting password doesn't lead to having all superusers compromised but not setting the password will guarantee that you'll never have all superusers compromised. the reason is: when you don't set the password, any password login attempt to postgres user will be denied whereas you can still use it yourself by trust.

                  – ardilgulez
                  Mar 24 '18 at 0:39

















                • What's the reason for this rule of thumb?

                  – Gershom Maes
                  Mar 21 '18 at 20:06











                • So that you can never have all your superusers conpromised.

                  – ardilgulez
                  Mar 22 '18 at 10:34











                • How can setting a password for postgres lead to having all superusers compromised?

                  – Gershom Maes
                  Mar 22 '18 at 17:11






                • 2





                  setting password doesn't lead to having all superusers compromised but not setting the password will guarantee that you'll never have all superusers compromised. the reason is: when you don't set the password, any password login attempt to postgres user will be denied whereas you can still use it yourself by trust.

                  – ardilgulez
                  Mar 24 '18 at 0:39
















                What's the reason for this rule of thumb?

                – Gershom Maes
                Mar 21 '18 at 20:06





                What's the reason for this rule of thumb?

                – Gershom Maes
                Mar 21 '18 at 20:06













                So that you can never have all your superusers conpromised.

                – ardilgulez
                Mar 22 '18 at 10:34





                So that you can never have all your superusers conpromised.

                – ardilgulez
                Mar 22 '18 at 10:34













                How can setting a password for postgres lead to having all superusers compromised?

                – Gershom Maes
                Mar 22 '18 at 17:11





                How can setting a password for postgres lead to having all superusers compromised?

                – Gershom Maes
                Mar 22 '18 at 17:11




                2




                2





                setting password doesn't lead to having all superusers compromised but not setting the password will guarantee that you'll never have all superusers compromised. the reason is: when you don't set the password, any password login attempt to postgres user will be denied whereas you can still use it yourself by trust.

                – ardilgulez
                Mar 24 '18 at 0:39





                setting password doesn't lead to having all superusers compromised but not setting the password will guarantee that you'll never have all superusers compromised. the reason is: when you don't set the password, any password login attempt to postgres user will be denied whereas you can still use it yourself by trust.

                – ardilgulez
                Mar 24 '18 at 0:39











                0














                I just wanted to add that you should also check if your password is expired.



                See Postgres password authentication fails for details.






                share|improve this answer




















                • 1





                  Please add some details and a summary of what that link provides in case in the future the link no longer exists. Otherwise this is likely to be flagged as a low-quality/link only answer.

                  – Tanner
                  Sep 2 '14 at 15:24






                • 1





                  Thanks. I think my answer is clear enough.

                  – Jörg
                  Sep 2 '14 at 15:28











                • I'd have a read of this: meta.stackexchange.com/questions/8231/…

                  – Tanner
                  Sep 2 '14 at 15:34















                0














                I just wanted to add that you should also check if your password is expired.



                See Postgres password authentication fails for details.






                share|improve this answer




















                • 1





                  Please add some details and a summary of what that link provides in case in the future the link no longer exists. Otherwise this is likely to be flagged as a low-quality/link only answer.

                  – Tanner
                  Sep 2 '14 at 15:24






                • 1





                  Thanks. I think my answer is clear enough.

                  – Jörg
                  Sep 2 '14 at 15:28











                • I'd have a read of this: meta.stackexchange.com/questions/8231/…

                  – Tanner
                  Sep 2 '14 at 15:34













                0












                0








                0







                I just wanted to add that you should also check if your password is expired.



                See Postgres password authentication fails for details.






                share|improve this answer















                I just wanted to add that you should also check if your password is expired.



                See Postgres password authentication fails for details.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 23 '17 at 12:34









                Community

                11




                11










                answered Sep 2 '14 at 15:20









                JörgJörg

                2,17811517




                2,17811517







                • 1





                  Please add some details and a summary of what that link provides in case in the future the link no longer exists. Otherwise this is likely to be flagged as a low-quality/link only answer.

                  – Tanner
                  Sep 2 '14 at 15:24






                • 1





                  Thanks. I think my answer is clear enough.

                  – Jörg
                  Sep 2 '14 at 15:28











                • I'd have a read of this: meta.stackexchange.com/questions/8231/…

                  – Tanner
                  Sep 2 '14 at 15:34












                • 1





                  Please add some details and a summary of what that link provides in case in the future the link no longer exists. Otherwise this is likely to be flagged as a low-quality/link only answer.

                  – Tanner
                  Sep 2 '14 at 15:24






                • 1





                  Thanks. I think my answer is clear enough.

                  – Jörg
                  Sep 2 '14 at 15:28











                • I'd have a read of this: meta.stackexchange.com/questions/8231/…

                  – Tanner
                  Sep 2 '14 at 15:34







                1




                1





                Please add some details and a summary of what that link provides in case in the future the link no longer exists. Otherwise this is likely to be flagged as a low-quality/link only answer.

                – Tanner
                Sep 2 '14 at 15:24





                Please add some details and a summary of what that link provides in case in the future the link no longer exists. Otherwise this is likely to be flagged as a low-quality/link only answer.

                – Tanner
                Sep 2 '14 at 15:24




                1




                1





                Thanks. I think my answer is clear enough.

                – Jörg
                Sep 2 '14 at 15:28





                Thanks. I think my answer is clear enough.

                – Jörg
                Sep 2 '14 at 15:28













                I'd have a read of this: meta.stackexchange.com/questions/8231/…

                – Tanner
                Sep 2 '14 at 15:34





                I'd have a read of this: meta.stackexchange.com/questions/8231/…

                – Tanner
                Sep 2 '14 at 15:34











                0














                Here are some combinations which I tried to login:



                # login via user foo
                psql -Ufoo -h localhost

                sudo -u postgres psql postgres

                # user foo login to postgres db
                psql -Ufoo -h localhost -d postgres





                share|improve this answer



























                  0














                  Here are some combinations which I tried to login:



                  # login via user foo
                  psql -Ufoo -h localhost

                  sudo -u postgres psql postgres

                  # user foo login to postgres db
                  psql -Ufoo -h localhost -d postgres





                  share|improve this answer

























                    0












                    0








                    0







                    Here are some combinations which I tried to login:



                    # login via user foo
                    psql -Ufoo -h localhost

                    sudo -u postgres psql postgres

                    # user foo login to postgres db
                    psql -Ufoo -h localhost -d postgres





                    share|improve this answer













                    Here are some combinations which I tried to login:



                    # login via user foo
                    psql -Ufoo -h localhost

                    sudo -u postgres psql postgres

                    # user foo login to postgres db
                    psql -Ufoo -h localhost -d postgres






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 10 '14 at 10:16









                    tokhitokhi

                    12.9k167391




                    12.9k167391





















                        0














                        i had a similar problem.
                        Ubuntu was left me log in in console with any password for superuser.
                        Except when i connected with -h localhost in psql line command.



                        I Observed too that "localhost:8080/MyJSPSiteLogIn" - showed: Fatal: autentication error with user "user".



                        pg_hba.conf was ok.



                        I noted had two versions of postgres running in the same service.



                        Solved - uninstalling inutil version.






                        share|improve this answer



























                          0














                          i had a similar problem.
                          Ubuntu was left me log in in console with any password for superuser.
                          Except when i connected with -h localhost in psql line command.



                          I Observed too that "localhost:8080/MyJSPSiteLogIn" - showed: Fatal: autentication error with user "user".



                          pg_hba.conf was ok.



                          I noted had two versions of postgres running in the same service.



                          Solved - uninstalling inutil version.






                          share|improve this answer

























                            0












                            0








                            0







                            i had a similar problem.
                            Ubuntu was left me log in in console with any password for superuser.
                            Except when i connected with -h localhost in psql line command.



                            I Observed too that "localhost:8080/MyJSPSiteLogIn" - showed: Fatal: autentication error with user "user".



                            pg_hba.conf was ok.



                            I noted had two versions of postgres running in the same service.



                            Solved - uninstalling inutil version.






                            share|improve this answer













                            i had a similar problem.
                            Ubuntu was left me log in in console with any password for superuser.
                            Except when i connected with -h localhost in psql line command.



                            I Observed too that "localhost:8080/MyJSPSiteLogIn" - showed: Fatal: autentication error with user "user".



                            pg_hba.conf was ok.



                            I noted had two versions of postgres running in the same service.



                            Solved - uninstalling inutil version.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 30 '18 at 19:51









                            David UvmDavid Uvm

                            1




                            1





















                                -1














                                I hope this will help you short of time.
                                You can change the password of postgres sql by using bellow command.



                                Command



                                sudo -u postgres psql



                                And next you can update the password



                                Command



                                Alter user postgres password 'YOUR_NEW_PASSWORD';






                                share|improve this answer


















                                • 1





                                  Your answer just contains information, that has already been added: stackoverflow.com/a/7696398/8283469

                                  – L. Guthardt
                                  Jul 2 '18 at 11:21















                                -1














                                I hope this will help you short of time.
                                You can change the password of postgres sql by using bellow command.



                                Command



                                sudo -u postgres psql



                                And next you can update the password



                                Command



                                Alter user postgres password 'YOUR_NEW_PASSWORD';






                                share|improve this answer


















                                • 1





                                  Your answer just contains information, that has already been added: stackoverflow.com/a/7696398/8283469

                                  – L. Guthardt
                                  Jul 2 '18 at 11:21













                                -1












                                -1








                                -1







                                I hope this will help you short of time.
                                You can change the password of postgres sql by using bellow command.



                                Command



                                sudo -u postgres psql



                                And next you can update the password



                                Command



                                Alter user postgres password 'YOUR_NEW_PASSWORD';






                                share|improve this answer













                                I hope this will help you short of time.
                                You can change the password of postgres sql by using bellow command.



                                Command



                                sudo -u postgres psql



                                And next you can update the password



                                Command



                                Alter user postgres password 'YOUR_NEW_PASSWORD';







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jul 2 '18 at 10:58









                                Sonu patelSonu patel

                                696




                                696







                                • 1





                                  Your answer just contains information, that has already been added: stackoverflow.com/a/7696398/8283469

                                  – L. Guthardt
                                  Jul 2 '18 at 11:21












                                • 1





                                  Your answer just contains information, that has already been added: stackoverflow.com/a/7696398/8283469

                                  – L. Guthardt
                                  Jul 2 '18 at 11:21







                                1




                                1





                                Your answer just contains information, that has already been added: stackoverflow.com/a/7696398/8283469

                                – L. Guthardt
                                Jul 2 '18 at 11:21





                                Your answer just contains information, that has already been added: stackoverflow.com/a/7696398/8283469

                                – L. Guthardt
                                Jul 2 '18 at 11:21

















                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7695962%2fpostgresql-password-authentication-failed-for-user-postgres%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                                Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                                Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved