postgresql installation : initdb data directory not empty? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Come Celebrate our 10 Year Anniversary!can not connect via SSH to a remote Postgresql databaseunable to connect to PostgreSQL 8.4 on Ubuntu 10.04 serverRoundcube can't connect to PostgreSQL databasePostgreSQL service initdb doesn't workPostgresql unintended upgrade to 9.2.3Cannot connect to PostgreSQL unix domain socketAfter upgrading to PostgreSQL 9.4, unable to connect from localhostUnable to connect to postgresql 9.6 server from 9.4 clientpostgresql track counts and autovacuum is not workinghow to install postgresql on centos 6.2

Protagonist's race is hidden - should I reveal it?

Simulate round-robin tournament draw

Why do people think Winterfell crypts is the safest place for women, children & old people?

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

Why is arima in R one time step off?

Marquee sign letters

SQL Server placement of master database files vs resource database files

How to compute a Jacobian using polar coordinates?

Are these square matrices always diagonalisable?

Writing a T-SQL stored procedure to receive 4 numbers and insert them into a table

What *exactly* is electrical current, voltage, and resistance?

Is it appropriate to mention a relatable company blog post when you're asked about the company?

In search of the origins of term censor, I hit a dead end stuck with the greek term, to censor, λογοκρίνω

How did Elite on the NES work?

Does a Draconic Bloodline sorcerer's doubled proficiency bonus for Charisma checks against dragons apply to all dragon types or only the chosen one?

Does using the Inspiration rules for character defects encourage My Guy Syndrome?

Co-worker works way more than he should

Will I lose my paid in full property

Can gravitational waves pass through a black hole?

What's the difference between using dependency injection with a container and using a service locator?

Arriving in Atlanta (after US Preclearance in Dublin). Will I go through TSA security in Atlanta to transfer to a connecting flight?

Israeli soda type drink

Was there ever a LEGO store in Miami International Airport?

France's Public Holidays' Puzzle



postgresql installation : initdb data directory not empty?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Come Celebrate our 10 Year Anniversary!can not connect via SSH to a remote Postgresql databaseunable to connect to PostgreSQL 8.4 on Ubuntu 10.04 serverRoundcube can't connect to PostgreSQL databasePostgreSQL service initdb doesn't workPostgresql unintended upgrade to 9.2.3Cannot connect to PostgreSQL unix domain socketAfter upgrading to PostgreSQL 9.4, unable to connect from localhostUnable to connect to postgresql 9.6 server from 9.4 clientpostgresql track counts and autovacuum is not workinghow to install postgresql on centos 6.2



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








15















I am trying to create the postgresql database.



When I install PostgreSQL, I gave this command:



sudo yum install postgresql postgresql-server


and later I modified the config file:



sudo vim /var/lib/pgsql/data/pg_hba.conf


and modified as



local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all all 0.0.0.0/0 md5


While I am trying to startup the postgresql service:



sudo service postgresql initdb

> Data directory is not empty! [FAILED]

sudo chkconfig postgresql on

sudo service postgresql start

Starting postgresql service: [ OK ]


What is caused these errors and how do I fix them?










share|improve this question






























    15















    I am trying to create the postgresql database.



    When I install PostgreSQL, I gave this command:



    sudo yum install postgresql postgresql-server


    and later I modified the config file:



    sudo vim /var/lib/pgsql/data/pg_hba.conf


    and modified as



    local all all trust
    host all all 127.0.0.1/32 trust
    host all all ::1/128 trust
    host all all 0.0.0.0/0 md5


    While I am trying to startup the postgresql service:



    sudo service postgresql initdb

    > Data directory is not empty! [FAILED]

    sudo chkconfig postgresql on

    sudo service postgresql start

    Starting postgresql service: [ OK ]


    What is caused these errors and how do I fix them?










    share|improve this question


























      15












      15








      15


      1






      I am trying to create the postgresql database.



      When I install PostgreSQL, I gave this command:



      sudo yum install postgresql postgresql-server


      and later I modified the config file:



      sudo vim /var/lib/pgsql/data/pg_hba.conf


      and modified as



      local all all trust
      host all all 127.0.0.1/32 trust
      host all all ::1/128 trust
      host all all 0.0.0.0/0 md5


      While I am trying to startup the postgresql service:



      sudo service postgresql initdb

      > Data directory is not empty! [FAILED]

      sudo chkconfig postgresql on

      sudo service postgresql start

      Starting postgresql service: [ OK ]


      What is caused these errors and how do I fix them?










      share|improve this question
















      I am trying to create the postgresql database.



      When I install PostgreSQL, I gave this command:



      sudo yum install postgresql postgresql-server


      and later I modified the config file:



      sudo vim /var/lib/pgsql/data/pg_hba.conf


      and modified as



      local all all trust
      host all all 127.0.0.1/32 trust
      host all all ::1/128 trust
      host all all 0.0.0.0/0 md5


      While I am trying to startup the postgresql service:



      sudo service postgresql initdb

      > Data directory is not empty! [FAILED]

      sudo chkconfig postgresql on

      sudo service postgresql start

      Starting postgresql service: [ OK ]


      What is caused these errors and how do I fix them?







      postgresql installation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 7 '16 at 17:51









      Eric Leschinski

      1,40441625




      1,40441625










      asked May 8 '13 at 8:14









      sridharsridhar

      78114




      78114




















          4 Answers
          4






          active

          oldest

          votes


















          16














          Initdb should only be run once. It will create the directory where you'll keep the config files and (usually) the actual database. You've obviously already done that already; otherwrise there wouldn't be any pg_hba.conf for you to edit.



          So, just don't run postgresql initdb again, unless you are doing a complete reinstall.






          share|improve this answer























          • thanks for the reply.. i run it twice... you mean the its not the problem in installation..

            – sridhar
            May 8 '13 at 8:36












          • I mean that there is no problem with your installation, at least not any that you've shown. The only thing that is failing is doing initdb more than once, and that should fail - everything else shows as OK. If there's any other problem, it would help if you could describe it.

            – Jenny D
            May 8 '13 at 8:39











          • Thank you very much.. then its not a problem.. if i face a problem i will let you know..

            – sridhar
            May 8 '13 at 8:47


















          13














          From here:



          If you're completely wiping & reinstalling a Postgres DB, when running initdb like:



          service postgresql-9.2 initdb -E 'UTF8' --pgdata="/foo/bar/"



          you can encounter this service error:




          Data directory is not empty! [FAILED]




          To fix it (and this is the nuclear option -- all db data is wiped!)



          On Amazon Linux (2014-x):



          rm -rf /var/lib/pgsql9/data



          On CentOS (6.x)



          rm -rf /var/lib/pgsql/9.2/data



          Now try the initdb command again and it should work this time:



          service postgresql-9.2 initdb






          share|improve this answer






























            4














            On systemd based systems like RHEL/CentOS 7 and Fedora the procedure for running initdb is somewhat different. This is no longer done by the init scripts (which no longer exist), and the new procedure is much closer to the upstream instructions.



            You must first su to the postgres user, and then run initdb or pg_ctl initdb. It's not necessary to provide a data directory if you are using a Red Hat build as its default automatically chooses the default data directory /var/lib/pgsql.



            For example:



            # su - postgres
            $ pg_ctl initdb
            $ exit
            #


            Of course, you only do this once, on first installation, to set up the initial data directory. You would not do it again unless you were creating a completely new installation or restoring from a disaster.






            share|improve this answer






























              3














              I had the same issue, using PostgreSQL 9.3 on CentOS 6.



              I deleted the /var/lib/pgsql/9.3/data folder, then re-ran the command



              sudo service postgresql-9.3 initdb


              ... which successfully initialised the db service again.






              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
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f505924%2fpostgresql-installation-initdb-data-directory-not-empty%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                16














                Initdb should only be run once. It will create the directory where you'll keep the config files and (usually) the actual database. You've obviously already done that already; otherwrise there wouldn't be any pg_hba.conf for you to edit.



                So, just don't run postgresql initdb again, unless you are doing a complete reinstall.






                share|improve this answer























                • thanks for the reply.. i run it twice... you mean the its not the problem in installation..

                  – sridhar
                  May 8 '13 at 8:36












                • I mean that there is no problem with your installation, at least not any that you've shown. The only thing that is failing is doing initdb more than once, and that should fail - everything else shows as OK. If there's any other problem, it would help if you could describe it.

                  – Jenny D
                  May 8 '13 at 8:39











                • Thank you very much.. then its not a problem.. if i face a problem i will let you know..

                  – sridhar
                  May 8 '13 at 8:47















                16














                Initdb should only be run once. It will create the directory where you'll keep the config files and (usually) the actual database. You've obviously already done that already; otherwrise there wouldn't be any pg_hba.conf for you to edit.



                So, just don't run postgresql initdb again, unless you are doing a complete reinstall.






                share|improve this answer























                • thanks for the reply.. i run it twice... you mean the its not the problem in installation..

                  – sridhar
                  May 8 '13 at 8:36












                • I mean that there is no problem with your installation, at least not any that you've shown. The only thing that is failing is doing initdb more than once, and that should fail - everything else shows as OK. If there's any other problem, it would help if you could describe it.

                  – Jenny D
                  May 8 '13 at 8:39











                • Thank you very much.. then its not a problem.. if i face a problem i will let you know..

                  – sridhar
                  May 8 '13 at 8:47













                16












                16








                16







                Initdb should only be run once. It will create the directory where you'll keep the config files and (usually) the actual database. You've obviously already done that already; otherwrise there wouldn't be any pg_hba.conf for you to edit.



                So, just don't run postgresql initdb again, unless you are doing a complete reinstall.






                share|improve this answer













                Initdb should only be run once. It will create the directory where you'll keep the config files and (usually) the actual database. You've obviously already done that already; otherwrise there wouldn't be any pg_hba.conf for you to edit.



                So, just don't run postgresql initdb again, unless you are doing a complete reinstall.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 8 '13 at 8:35









                Jenny DJenny D

                24.3k116196




                24.3k116196












                • thanks for the reply.. i run it twice... you mean the its not the problem in installation..

                  – sridhar
                  May 8 '13 at 8:36












                • I mean that there is no problem with your installation, at least not any that you've shown. The only thing that is failing is doing initdb more than once, and that should fail - everything else shows as OK. If there's any other problem, it would help if you could describe it.

                  – Jenny D
                  May 8 '13 at 8:39











                • Thank you very much.. then its not a problem.. if i face a problem i will let you know..

                  – sridhar
                  May 8 '13 at 8:47

















                • thanks for the reply.. i run it twice... you mean the its not the problem in installation..

                  – sridhar
                  May 8 '13 at 8:36












                • I mean that there is no problem with your installation, at least not any that you've shown. The only thing that is failing is doing initdb more than once, and that should fail - everything else shows as OK. If there's any other problem, it would help if you could describe it.

                  – Jenny D
                  May 8 '13 at 8:39











                • Thank you very much.. then its not a problem.. if i face a problem i will let you know..

                  – sridhar
                  May 8 '13 at 8:47
















                thanks for the reply.. i run it twice... you mean the its not the problem in installation..

                – sridhar
                May 8 '13 at 8:36






                thanks for the reply.. i run it twice... you mean the its not the problem in installation..

                – sridhar
                May 8 '13 at 8:36














                I mean that there is no problem with your installation, at least not any that you've shown. The only thing that is failing is doing initdb more than once, and that should fail - everything else shows as OK. If there's any other problem, it would help if you could describe it.

                – Jenny D
                May 8 '13 at 8:39





                I mean that there is no problem with your installation, at least not any that you've shown. The only thing that is failing is doing initdb more than once, and that should fail - everything else shows as OK. If there's any other problem, it would help if you could describe it.

                – Jenny D
                May 8 '13 at 8:39













                Thank you very much.. then its not a problem.. if i face a problem i will let you know..

                – sridhar
                May 8 '13 at 8:47





                Thank you very much.. then its not a problem.. if i face a problem i will let you know..

                – sridhar
                May 8 '13 at 8:47













                13














                From here:



                If you're completely wiping & reinstalling a Postgres DB, when running initdb like:



                service postgresql-9.2 initdb -E 'UTF8' --pgdata="/foo/bar/"



                you can encounter this service error:




                Data directory is not empty! [FAILED]




                To fix it (and this is the nuclear option -- all db data is wiped!)



                On Amazon Linux (2014-x):



                rm -rf /var/lib/pgsql9/data



                On CentOS (6.x)



                rm -rf /var/lib/pgsql/9.2/data



                Now try the initdb command again and it should work this time:



                service postgresql-9.2 initdb






                share|improve this answer



























                  13














                  From here:



                  If you're completely wiping & reinstalling a Postgres DB, when running initdb like:



                  service postgresql-9.2 initdb -E 'UTF8' --pgdata="/foo/bar/"



                  you can encounter this service error:




                  Data directory is not empty! [FAILED]




                  To fix it (and this is the nuclear option -- all db data is wiped!)



                  On Amazon Linux (2014-x):



                  rm -rf /var/lib/pgsql9/data



                  On CentOS (6.x)



                  rm -rf /var/lib/pgsql/9.2/data



                  Now try the initdb command again and it should work this time:



                  service postgresql-9.2 initdb






                  share|improve this answer

























                    13












                    13








                    13







                    From here:



                    If you're completely wiping & reinstalling a Postgres DB, when running initdb like:



                    service postgresql-9.2 initdb -E 'UTF8' --pgdata="/foo/bar/"



                    you can encounter this service error:




                    Data directory is not empty! [FAILED]




                    To fix it (and this is the nuclear option -- all db data is wiped!)



                    On Amazon Linux (2014-x):



                    rm -rf /var/lib/pgsql9/data



                    On CentOS (6.x)



                    rm -rf /var/lib/pgsql/9.2/data



                    Now try the initdb command again and it should work this time:



                    service postgresql-9.2 initdb






                    share|improve this answer













                    From here:



                    If you're completely wiping & reinstalling a Postgres DB, when running initdb like:



                    service postgresql-9.2 initdb -E 'UTF8' --pgdata="/foo/bar/"



                    you can encounter this service error:




                    Data directory is not empty! [FAILED]




                    To fix it (and this is the nuclear option -- all db data is wiped!)



                    On Amazon Linux (2014-x):



                    rm -rf /var/lib/pgsql9/data



                    On CentOS (6.x)



                    rm -rf /var/lib/pgsql/9.2/data



                    Now try the initdb command again and it should work this time:



                    service postgresql-9.2 initdb







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 18 '16 at 4:02









                    sv.sv.

                    23134




                    23134





















                        4














                        On systemd based systems like RHEL/CentOS 7 and Fedora the procedure for running initdb is somewhat different. This is no longer done by the init scripts (which no longer exist), and the new procedure is much closer to the upstream instructions.



                        You must first su to the postgres user, and then run initdb or pg_ctl initdb. It's not necessary to provide a data directory if you are using a Red Hat build as its default automatically chooses the default data directory /var/lib/pgsql.



                        For example:



                        # su - postgres
                        $ pg_ctl initdb
                        $ exit
                        #


                        Of course, you only do this once, on first installation, to set up the initial data directory. You would not do it again unless you were creating a completely new installation or restoring from a disaster.






                        share|improve this answer



























                          4














                          On systemd based systems like RHEL/CentOS 7 and Fedora the procedure for running initdb is somewhat different. This is no longer done by the init scripts (which no longer exist), and the new procedure is much closer to the upstream instructions.



                          You must first su to the postgres user, and then run initdb or pg_ctl initdb. It's not necessary to provide a data directory if you are using a Red Hat build as its default automatically chooses the default data directory /var/lib/pgsql.



                          For example:



                          # su - postgres
                          $ pg_ctl initdb
                          $ exit
                          #


                          Of course, you only do this once, on first installation, to set up the initial data directory. You would not do it again unless you were creating a completely new installation or restoring from a disaster.






                          share|improve this answer

























                            4












                            4








                            4







                            On systemd based systems like RHEL/CentOS 7 and Fedora the procedure for running initdb is somewhat different. This is no longer done by the init scripts (which no longer exist), and the new procedure is much closer to the upstream instructions.



                            You must first su to the postgres user, and then run initdb or pg_ctl initdb. It's not necessary to provide a data directory if you are using a Red Hat build as its default automatically chooses the default data directory /var/lib/pgsql.



                            For example:



                            # su - postgres
                            $ pg_ctl initdb
                            $ exit
                            #


                            Of course, you only do this once, on first installation, to set up the initial data directory. You would not do it again unless you were creating a completely new installation or restoring from a disaster.






                            share|improve this answer













                            On systemd based systems like RHEL/CentOS 7 and Fedora the procedure for running initdb is somewhat different. This is no longer done by the init scripts (which no longer exist), and the new procedure is much closer to the upstream instructions.



                            You must first su to the postgres user, and then run initdb or pg_ctl initdb. It's not necessary to provide a data directory if you are using a Red Hat build as its default automatically chooses the default data directory /var/lib/pgsql.



                            For example:



                            # su - postgres
                            $ pg_ctl initdb
                            $ exit
                            #


                            Of course, you only do this once, on first installation, to set up the initial data directory. You would not do it again unless you were creating a completely new installation or restoring from a disaster.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 21 '15 at 3:03









                            Michael HamptonMichael Hampton

                            175k27321651




                            175k27321651





















                                3














                                I had the same issue, using PostgreSQL 9.3 on CentOS 6.



                                I deleted the /var/lib/pgsql/9.3/data folder, then re-ran the command



                                sudo service postgresql-9.3 initdb


                                ... which successfully initialised the db service again.






                                share|improve this answer



























                                  3














                                  I had the same issue, using PostgreSQL 9.3 on CentOS 6.



                                  I deleted the /var/lib/pgsql/9.3/data folder, then re-ran the command



                                  sudo service postgresql-9.3 initdb


                                  ... which successfully initialised the db service again.






                                  share|improve this answer

























                                    3












                                    3








                                    3







                                    I had the same issue, using PostgreSQL 9.3 on CentOS 6.



                                    I deleted the /var/lib/pgsql/9.3/data folder, then re-ran the command



                                    sudo service postgresql-9.3 initdb


                                    ... which successfully initialised the db service again.






                                    share|improve this answer













                                    I had the same issue, using PostgreSQL 9.3 on CentOS 6.



                                    I deleted the /var/lib/pgsql/9.3/data folder, then re-ran the command



                                    sudo service postgresql-9.3 initdb


                                    ... which successfully initialised the db service again.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Oct 12 '14 at 10:28









                                    Fuzzy AnalysisFuzzy Analysis

                                    1315




                                    1315



























                                        draft saved

                                        draft discarded
















































                                        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%2f505924%2fpostgresql-installation-initdb-data-directory-not-empty%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

                                        Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

                                        Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

                                        What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company