Mongod: Command Not Found (OS X)












17














I am trying to test MongoDB and I have it all downloaded and moved into the root folder. I can navigate to the folder that holds the mongod, but when I try to run it by typing "mongod" into my terminal, I get a message that says:




"mongod: command not found"











share|improve this question





























    17














    I am trying to test MongoDB and I have it all downloaded and moved into the root folder. I can navigate to the folder that holds the mongod, but when I try to run it by typing "mongod" into my terminal, I get a message that says:




    "mongod: command not found"











    share|improve this question



























      17












      17








      17


      5





      I am trying to test MongoDB and I have it all downloaded and moved into the root folder. I can navigate to the folder that holds the mongod, but when I try to run it by typing "mongod" into my terminal, I get a message that says:




      "mongod: command not found"











      share|improve this question















      I am trying to test MongoDB and I have it all downloaded and moved into the root folder. I can navigate to the folder that holds the mongod, but when I try to run it by typing "mongod" into my terminal, I get a message that says:




      "mongod: command not found"








      macos mongodb






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 12 '18 at 3:40









      Cœur

      17.4k9103145




      17.4k9103145










      asked Apr 4 '14 at 12:26









      MissElizabeth

      2411311




      2411311
























          5 Answers
          5






          active

          oldest

          votes


















          15














          Both answers above are correct.
          You can either specify the path in one of the following files: .profile, .bashrc, or .bash_profile



          export PATH="$PATH:/usr/local/mongodb/bin"


          then call the daemon or the shell directly



          mongod
          mongo


          Or for the commands not in the $PATH, use ./mongo or ./mongod from the directory containing these files. This solution can be verbose has you will have to eventually append the whole path when calling these commands from another directory.



          /usr/local/mongodb/bin/mongod
          or
          /usr/local/mongodb/bin$ ./mongod





          share|improve this answer

















          • 1




            NOTE: if you update your Mac to Sierra you will need to re-export your paths as shown above.
            – msmfsd
            Dec 28 '16 at 2:14










          • cool,,,, this is working man
            – GvSharma
            Apr 25 '18 at 18:42



















          12














          "Mongod" isn't a stand-alone command. You need to run the command like so ./mongodb/bin/mongod



          I used http://www.bigspaceship.com/mongodb-on-mac/ to help me answer this question.






          share|improve this answer





























            4














            You need to add the name of the folder that contains the command mongod into your PATH so your shell knows where to find it.



            So, if mongod is in /usr/bin/freddyfrog, you would edit ~/.profile and find the line that says PATH= and edit it to look like this:



            export PATH=${PATH}:/usr/bin/freddyfrog


            Then login again to make it take effect.






            share|improve this answer





























              2














              3 steps:



              Step 1:



              export PATH="$PATH:/usr/local/mongodb/bin"


              OR



              export PATH="$PATH:/usr/local/opt/mongodb@3.2/bin"


              (replace version number with your local version)



              The first step will allow you to run the command, but will get you another error: "/data/db does not exit" so you have to



              Step 2 :



              sudo mkdir -p /data/db


              Now /data/db is read only, but it has to be writable also so



              Step 3 :



              sudo chown -R USERNAME /data/db 





              share|improve this answer































                0














                In root directory



                sudo mkdir data
                cd data
                mkdir db


                then



                sudo chown -R yourUsername /data/ 


                copy path of your mongodb/bin downloaded folder (I suggest you put it in home folder not root dir)



                enter image description here



                in terminal



                export PATH="paste the link here :$PATH"



                now it should work but if not



                In case you are using different Unix shell and
                trying to execute mongod within visual studio code( for example ),
                make sure to read the documentation to link PATH.



                For example, if you are using zsh create .zprofile in your home directory.



                touch .zprofile



                copy your previously made PATH into .zprofile



                enter image description here



                enter image description here



                Now everything should work as expected.






                share|improve this answer























                  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%2f22862808%2fmongod-command-not-found-os-x%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  5 Answers
                  5






                  active

                  oldest

                  votes








                  5 Answers
                  5






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  15














                  Both answers above are correct.
                  You can either specify the path in one of the following files: .profile, .bashrc, or .bash_profile



                  export PATH="$PATH:/usr/local/mongodb/bin"


                  then call the daemon or the shell directly



                  mongod
                  mongo


                  Or for the commands not in the $PATH, use ./mongo or ./mongod from the directory containing these files. This solution can be verbose has you will have to eventually append the whole path when calling these commands from another directory.



                  /usr/local/mongodb/bin/mongod
                  or
                  /usr/local/mongodb/bin$ ./mongod





                  share|improve this answer

















                  • 1




                    NOTE: if you update your Mac to Sierra you will need to re-export your paths as shown above.
                    – msmfsd
                    Dec 28 '16 at 2:14










                  • cool,,,, this is working man
                    – GvSharma
                    Apr 25 '18 at 18:42
















                  15














                  Both answers above are correct.
                  You can either specify the path in one of the following files: .profile, .bashrc, or .bash_profile



                  export PATH="$PATH:/usr/local/mongodb/bin"


                  then call the daemon or the shell directly



                  mongod
                  mongo


                  Or for the commands not in the $PATH, use ./mongo or ./mongod from the directory containing these files. This solution can be verbose has you will have to eventually append the whole path when calling these commands from another directory.



                  /usr/local/mongodb/bin/mongod
                  or
                  /usr/local/mongodb/bin$ ./mongod





                  share|improve this answer

















                  • 1




                    NOTE: if you update your Mac to Sierra you will need to re-export your paths as shown above.
                    – msmfsd
                    Dec 28 '16 at 2:14










                  • cool,,,, this is working man
                    – GvSharma
                    Apr 25 '18 at 18:42














                  15












                  15








                  15






                  Both answers above are correct.
                  You can either specify the path in one of the following files: .profile, .bashrc, or .bash_profile



                  export PATH="$PATH:/usr/local/mongodb/bin"


                  then call the daemon or the shell directly



                  mongod
                  mongo


                  Or for the commands not in the $PATH, use ./mongo or ./mongod from the directory containing these files. This solution can be verbose has you will have to eventually append the whole path when calling these commands from another directory.



                  /usr/local/mongodb/bin/mongod
                  or
                  /usr/local/mongodb/bin$ ./mongod





                  share|improve this answer












                  Both answers above are correct.
                  You can either specify the path in one of the following files: .profile, .bashrc, or .bash_profile



                  export PATH="$PATH:/usr/local/mongodb/bin"


                  then call the daemon or the shell directly



                  mongod
                  mongo


                  Or for the commands not in the $PATH, use ./mongo or ./mongod from the directory containing these files. This solution can be verbose has you will have to eventually append the whole path when calling these commands from another directory.



                  /usr/local/mongodb/bin/mongod
                  or
                  /usr/local/mongodb/bin$ ./mongod






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 8 '14 at 17:36









                  Laurent Jacquot

                  23626




                  23626








                  • 1




                    NOTE: if you update your Mac to Sierra you will need to re-export your paths as shown above.
                    – msmfsd
                    Dec 28 '16 at 2:14










                  • cool,,,, this is working man
                    – GvSharma
                    Apr 25 '18 at 18:42














                  • 1




                    NOTE: if you update your Mac to Sierra you will need to re-export your paths as shown above.
                    – msmfsd
                    Dec 28 '16 at 2:14










                  • cool,,,, this is working man
                    – GvSharma
                    Apr 25 '18 at 18:42








                  1




                  1




                  NOTE: if you update your Mac to Sierra you will need to re-export your paths as shown above.
                  – msmfsd
                  Dec 28 '16 at 2:14




                  NOTE: if you update your Mac to Sierra you will need to re-export your paths as shown above.
                  – msmfsd
                  Dec 28 '16 at 2:14












                  cool,,,, this is working man
                  – GvSharma
                  Apr 25 '18 at 18:42




                  cool,,,, this is working man
                  – GvSharma
                  Apr 25 '18 at 18:42













                  12














                  "Mongod" isn't a stand-alone command. You need to run the command like so ./mongodb/bin/mongod



                  I used http://www.bigspaceship.com/mongodb-on-mac/ to help me answer this question.






                  share|improve this answer


























                    12














                    "Mongod" isn't a stand-alone command. You need to run the command like so ./mongodb/bin/mongod



                    I used http://www.bigspaceship.com/mongodb-on-mac/ to help me answer this question.






                    share|improve this answer
























                      12












                      12








                      12






                      "Mongod" isn't a stand-alone command. You need to run the command like so ./mongodb/bin/mongod



                      I used http://www.bigspaceship.com/mongodb-on-mac/ to help me answer this question.






                      share|improve this answer












                      "Mongod" isn't a stand-alone command. You need to run the command like so ./mongodb/bin/mongod



                      I used http://www.bigspaceship.com/mongodb-on-mac/ to help me answer this question.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Apr 4 '14 at 12:34









                      MissElizabeth

                      2411311




                      2411311























                          4














                          You need to add the name of the folder that contains the command mongod into your PATH so your shell knows where to find it.



                          So, if mongod is in /usr/bin/freddyfrog, you would edit ~/.profile and find the line that says PATH= and edit it to look like this:



                          export PATH=${PATH}:/usr/bin/freddyfrog


                          Then login again to make it take effect.






                          share|improve this answer


























                            4














                            You need to add the name of the folder that contains the command mongod into your PATH so your shell knows where to find it.



                            So, if mongod is in /usr/bin/freddyfrog, you would edit ~/.profile and find the line that says PATH= and edit it to look like this:



                            export PATH=${PATH}:/usr/bin/freddyfrog


                            Then login again to make it take effect.






                            share|improve this answer
























                              4












                              4








                              4






                              You need to add the name of the folder that contains the command mongod into your PATH so your shell knows where to find it.



                              So, if mongod is in /usr/bin/freddyfrog, you would edit ~/.profile and find the line that says PATH= and edit it to look like this:



                              export PATH=${PATH}:/usr/bin/freddyfrog


                              Then login again to make it take effect.






                              share|improve this answer












                              You need to add the name of the folder that contains the command mongod into your PATH so your shell knows where to find it.



                              So, if mongod is in /usr/bin/freddyfrog, you would edit ~/.profile and find the line that says PATH= and edit it to look like this:



                              export PATH=${PATH}:/usr/bin/freddyfrog


                              Then login again to make it take effect.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Apr 4 '14 at 12:33









                              Mark Setchell

                              86.1k673172




                              86.1k673172























                                  2














                                  3 steps:



                                  Step 1:



                                  export PATH="$PATH:/usr/local/mongodb/bin"


                                  OR



                                  export PATH="$PATH:/usr/local/opt/mongodb@3.2/bin"


                                  (replace version number with your local version)



                                  The first step will allow you to run the command, but will get you another error: "/data/db does not exit" so you have to



                                  Step 2 :



                                  sudo mkdir -p /data/db


                                  Now /data/db is read only, but it has to be writable also so



                                  Step 3 :



                                  sudo chown -R USERNAME /data/db 





                                  share|improve this answer




























                                    2














                                    3 steps:



                                    Step 1:



                                    export PATH="$PATH:/usr/local/mongodb/bin"


                                    OR



                                    export PATH="$PATH:/usr/local/opt/mongodb@3.2/bin"


                                    (replace version number with your local version)



                                    The first step will allow you to run the command, but will get you another error: "/data/db does not exit" so you have to



                                    Step 2 :



                                    sudo mkdir -p /data/db


                                    Now /data/db is read only, but it has to be writable also so



                                    Step 3 :



                                    sudo chown -R USERNAME /data/db 





                                    share|improve this answer


























                                      2












                                      2








                                      2






                                      3 steps:



                                      Step 1:



                                      export PATH="$PATH:/usr/local/mongodb/bin"


                                      OR



                                      export PATH="$PATH:/usr/local/opt/mongodb@3.2/bin"


                                      (replace version number with your local version)



                                      The first step will allow you to run the command, but will get you another error: "/data/db does not exit" so you have to



                                      Step 2 :



                                      sudo mkdir -p /data/db


                                      Now /data/db is read only, but it has to be writable also so



                                      Step 3 :



                                      sudo chown -R USERNAME /data/db 





                                      share|improve this answer














                                      3 steps:



                                      Step 1:



                                      export PATH="$PATH:/usr/local/mongodb/bin"


                                      OR



                                      export PATH="$PATH:/usr/local/opt/mongodb@3.2/bin"


                                      (replace version number with your local version)



                                      The first step will allow you to run the command, but will get you another error: "/data/db does not exit" so you have to



                                      Step 2 :



                                      sudo mkdir -p /data/db


                                      Now /data/db is read only, but it has to be writable also so



                                      Step 3 :



                                      sudo chown -R USERNAME /data/db 






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Jul 3 '18 at 19:40









                                      retroGiant

                                      443413




                                      443413










                                      answered Jun 26 '18 at 13:33









                                      Haddad

                                      276




                                      276























                                          0














                                          In root directory



                                          sudo mkdir data
                                          cd data
                                          mkdir db


                                          then



                                          sudo chown -R yourUsername /data/ 


                                          copy path of your mongodb/bin downloaded folder (I suggest you put it in home folder not root dir)



                                          enter image description here



                                          in terminal



                                          export PATH="paste the link here :$PATH"



                                          now it should work but if not



                                          In case you are using different Unix shell and
                                          trying to execute mongod within visual studio code( for example ),
                                          make sure to read the documentation to link PATH.



                                          For example, if you are using zsh create .zprofile in your home directory.



                                          touch .zprofile



                                          copy your previously made PATH into .zprofile



                                          enter image description here



                                          enter image description here



                                          Now everything should work as expected.






                                          share|improve this answer




























                                            0














                                            In root directory



                                            sudo mkdir data
                                            cd data
                                            mkdir db


                                            then



                                            sudo chown -R yourUsername /data/ 


                                            copy path of your mongodb/bin downloaded folder (I suggest you put it in home folder not root dir)



                                            enter image description here



                                            in terminal



                                            export PATH="paste the link here :$PATH"



                                            now it should work but if not



                                            In case you are using different Unix shell and
                                            trying to execute mongod within visual studio code( for example ),
                                            make sure to read the documentation to link PATH.



                                            For example, if you are using zsh create .zprofile in your home directory.



                                            touch .zprofile



                                            copy your previously made PATH into .zprofile



                                            enter image description here



                                            enter image description here



                                            Now everything should work as expected.






                                            share|improve this answer


























                                              0












                                              0








                                              0






                                              In root directory



                                              sudo mkdir data
                                              cd data
                                              mkdir db


                                              then



                                              sudo chown -R yourUsername /data/ 


                                              copy path of your mongodb/bin downloaded folder (I suggest you put it in home folder not root dir)



                                              enter image description here



                                              in terminal



                                              export PATH="paste the link here :$PATH"



                                              now it should work but if not



                                              In case you are using different Unix shell and
                                              trying to execute mongod within visual studio code( for example ),
                                              make sure to read the documentation to link PATH.



                                              For example, if you are using zsh create .zprofile in your home directory.



                                              touch .zprofile



                                              copy your previously made PATH into .zprofile



                                              enter image description here



                                              enter image description here



                                              Now everything should work as expected.






                                              share|improve this answer














                                              In root directory



                                              sudo mkdir data
                                              cd data
                                              mkdir db


                                              then



                                              sudo chown -R yourUsername /data/ 


                                              copy path of your mongodb/bin downloaded folder (I suggest you put it in home folder not root dir)



                                              enter image description here



                                              in terminal



                                              export PATH="paste the link here :$PATH"



                                              now it should work but if not



                                              In case you are using different Unix shell and
                                              trying to execute mongod within visual studio code( for example ),
                                              make sure to read the documentation to link PATH.



                                              For example, if you are using zsh create .zprofile in your home directory.



                                              touch .zprofile



                                              copy your previously made PATH into .zprofile



                                              enter image description here



                                              enter image description here



                                              Now everything should work as expected.







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Nov 21 '18 at 10:42

























                                              answered Nov 21 '18 at 10:28









                                              ahmed younes

                                              3810




                                              3810






























                                                  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.





                                                  Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                  Please pay close attention to the following guidance:


                                                  • 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%2f22862808%2fmongod-command-not-found-os-x%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

                                                  Wiesbaden

                                                  Marschland

                                                  Dieringhausen