I think I am unable to relock my postgres psql account The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Come Celebrate our 10 Year Anniversary!Cannot change password for user postgres in postgresqlpsql empty database before restorePSQL error with restarting postgres in SSLCannot access psql after installing postgrespsql editor setting on UbuntuPSQL 64bit driver errorPostgres roles best practice implementationpg_dump: [archiver (db)] connection to database failed: FATAL: Peer authentication failed for user “postgres”PostgreSQL password issue with psqlparallize postgres queries with bash and psql?

The variadic template constructor of my class cannot modify my class members, why is that so?

Match Roman Numerals

How does ice melt when immersed in water

Can the DM override racial traits?

Windows 10: How to Lock (not sleep) laptop on lid close?

How is simplicity better than precision and clarity in prose?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Difference between "generating set" and free product?

Create an outline of font

Who or what is the being for whom Being is a question for Heidegger?

Derivation tree not rendering

Why is superheterodyning better than direct conversion?

Is every episode of "Where are my Pants?" identical?

Simulating Exploding Dice

Semisimplicity of the category of coherent sheaves?

how can a perfect fourth interval be considered either consonant or dissonant?

Python - Fishing Simulator

Change bounding box of math glyphs in LuaTeX

Grover's algorithm - DES circuit as oracle?

Arduino Pro Micro - switch off LEDs

Why not take a picture of a closer black hole?

Didn't get enough time to take a Coding Test - what to do now?

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

Can withdrawing asylum be illegal?



I think I am unable to relock my postgres psql account



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Come Celebrate our 10 Year Anniversary!Cannot change password for user postgres in postgresqlpsql empty database before restorePSQL error with restarting postgres in SSLCannot access psql after installing postgrespsql editor setting on UbuntuPSQL 64bit driver errorPostgres roles best practice implementationpg_dump: [archiver (db)] connection to database failed: FATAL: Peer authentication failed for user “postgres”PostgreSQL password issue with psqlparallize postgres queries with bash and psql?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.



When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).



I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.



Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.



What can I do?










share|improve this question







New contributor




Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.



    When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).



    I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.



    Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.



    What can I do?










    share|improve this question







    New contributor




    Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.



      When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).



      I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.



      Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.



      What can I do?










      share|improve this question







      New contributor




      Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.



      When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).



      I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.



      Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.



      What can I do?







      password ubuntu-18.04 psql






      share|improve this question







      New contributor




      Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Apr 9 at 3:53









      Humble-Data-22Humble-Data-22

      31




      31




      New contributor




      Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Authentication method "peer"



          If your authentication method is peer like



          local all postgres peer


          and/or



          local all all peer


          in pg_hba.conf, then connect as linux user postgres to the database.



          sudo -u postgres psql


          You won't need a password, even if set.



          Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".



          Authentication method "md5"



          If your authentication method is md5, then you will need the correct password to connect.



          Reset password




          1. Comment all existing lines starting with "local" in pg_hba.conf and add line



            local all postgres trust



          2. Restart postgres



            service postgresql restart



          3. Connect to database



            # as any linux user
            psql -U postgres
            # or as user postgres
            sudo -u postgres psql



          4. Change password



            ALTER USER postgres WITH PASSWORD 'password';



          5. Exit



            q



          6. Restore your changes in pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is



            # Database administrative login by Unix domain socket
            local all postgres peer

            # TYPE DATABASE USER ADDRESS METHOD

            # "local" is for Unix domain socket connections only
            local all all peer
            # IPv4 local connections:
            host all all 127.0.0.1/32 md5
            # IPv6 local connections:
            host all all ::1/128 md5
            # Allow replication connections from localhost, by a user with the
            # replication privilege.
            #local replication postgres peer
            #host replication postgres 127.0.0.1/32 md5
            #host replication postgres ::1/128 md5



          7. Restart postgres



            service postgresql restart


          Note 2:
          If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.






          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "2"
            ;
            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
            );



            );






            Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f962127%2fi-think-i-am-unable-to-relock-my-postgres-psql-account%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Authentication method "peer"



            If your authentication method is peer like



            local all postgres peer


            and/or



            local all all peer


            in pg_hba.conf, then connect as linux user postgres to the database.



            sudo -u postgres psql


            You won't need a password, even if set.



            Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".



            Authentication method "md5"



            If your authentication method is md5, then you will need the correct password to connect.



            Reset password




            1. Comment all existing lines starting with "local" in pg_hba.conf and add line



              local all postgres trust



            2. Restart postgres



              service postgresql restart



            3. Connect to database



              # as any linux user
              psql -U postgres
              # or as user postgres
              sudo -u postgres psql



            4. Change password



              ALTER USER postgres WITH PASSWORD 'password';



            5. Exit



              q



            6. Restore your changes in pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is



              # Database administrative login by Unix domain socket
              local all postgres peer

              # TYPE DATABASE USER ADDRESS METHOD

              # "local" is for Unix domain socket connections only
              local all all peer
              # IPv4 local connections:
              host all all 127.0.0.1/32 md5
              # IPv6 local connections:
              host all all ::1/128 md5
              # Allow replication connections from localhost, by a user with the
              # replication privilege.
              #local replication postgres peer
              #host replication postgres 127.0.0.1/32 md5
              #host replication postgres ::1/128 md5



            7. Restart postgres



              service postgresql restart


            Note 2:
            If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.






            share|improve this answer



























              0














              Authentication method "peer"



              If your authentication method is peer like



              local all postgres peer


              and/or



              local all all peer


              in pg_hba.conf, then connect as linux user postgres to the database.



              sudo -u postgres psql


              You won't need a password, even if set.



              Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".



              Authentication method "md5"



              If your authentication method is md5, then you will need the correct password to connect.



              Reset password




              1. Comment all existing lines starting with "local" in pg_hba.conf and add line



                local all postgres trust



              2. Restart postgres



                service postgresql restart



              3. Connect to database



                # as any linux user
                psql -U postgres
                # or as user postgres
                sudo -u postgres psql



              4. Change password



                ALTER USER postgres WITH PASSWORD 'password';



              5. Exit



                q



              6. Restore your changes in pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is



                # Database administrative login by Unix domain socket
                local all postgres peer

                # TYPE DATABASE USER ADDRESS METHOD

                # "local" is for Unix domain socket connections only
                local all all peer
                # IPv4 local connections:
                host all all 127.0.0.1/32 md5
                # IPv6 local connections:
                host all all ::1/128 md5
                # Allow replication connections from localhost, by a user with the
                # replication privilege.
                #local replication postgres peer
                #host replication postgres 127.0.0.1/32 md5
                #host replication postgres ::1/128 md5



              7. Restart postgres



                service postgresql restart


              Note 2:
              If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.






              share|improve this answer

























                0












                0








                0







                Authentication method "peer"



                If your authentication method is peer like



                local all postgres peer


                and/or



                local all all peer


                in pg_hba.conf, then connect as linux user postgres to the database.



                sudo -u postgres psql


                You won't need a password, even if set.



                Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".



                Authentication method "md5"



                If your authentication method is md5, then you will need the correct password to connect.



                Reset password




                1. Comment all existing lines starting with "local" in pg_hba.conf and add line



                  local all postgres trust



                2. Restart postgres



                  service postgresql restart



                3. Connect to database



                  # as any linux user
                  psql -U postgres
                  # or as user postgres
                  sudo -u postgres psql



                4. Change password



                  ALTER USER postgres WITH PASSWORD 'password';



                5. Exit



                  q



                6. Restore your changes in pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is



                  # Database administrative login by Unix domain socket
                  local all postgres peer

                  # TYPE DATABASE USER ADDRESS METHOD

                  # "local" is for Unix domain socket connections only
                  local all all peer
                  # IPv4 local connections:
                  host all all 127.0.0.1/32 md5
                  # IPv6 local connections:
                  host all all ::1/128 md5
                  # Allow replication connections from localhost, by a user with the
                  # replication privilege.
                  #local replication postgres peer
                  #host replication postgres 127.0.0.1/32 md5
                  #host replication postgres ::1/128 md5



                7. Restart postgres



                  service postgresql restart


                Note 2:
                If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.






                share|improve this answer













                Authentication method "peer"



                If your authentication method is peer like



                local all postgres peer


                and/or



                local all all peer


                in pg_hba.conf, then connect as linux user postgres to the database.



                sudo -u postgres psql


                You won't need a password, even if set.



                Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".



                Authentication method "md5"



                If your authentication method is md5, then you will need the correct password to connect.



                Reset password




                1. Comment all existing lines starting with "local" in pg_hba.conf and add line



                  local all postgres trust



                2. Restart postgres



                  service postgresql restart



                3. Connect to database



                  # as any linux user
                  psql -U postgres
                  # or as user postgres
                  sudo -u postgres psql



                4. Change password



                  ALTER USER postgres WITH PASSWORD 'password';



                5. Exit



                  q



                6. Restore your changes in pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is



                  # Database administrative login by Unix domain socket
                  local all postgres peer

                  # TYPE DATABASE USER ADDRESS METHOD

                  # "local" is for Unix domain socket connections only
                  local all all peer
                  # IPv4 local connections:
                  host all all 127.0.0.1/32 md5
                  # IPv6 local connections:
                  host all all ::1/128 md5
                  # Allow replication connections from localhost, by a user with the
                  # replication privilege.
                  #local replication postgres peer
                  #host replication postgres 127.0.0.1/32 md5
                  #host replication postgres ::1/128 md5



                7. Restart postgres



                  service postgresql restart


                Note 2:
                If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 9 at 8:24









                FreddyFreddy

                79119




                79119




















                    Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.









                    draft saved

                    draft discarded


















                    Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.












                    Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.











                    Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.














                    Thanks for contributing an answer to Server Fault!


                    • 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%2fserverfault.com%2fquestions%2f962127%2fi-think-i-am-unable-to-relock-my-postgres-psql-account%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

                    How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                    What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                    Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos