MongoDB: Setting up Windows Service












16















I have just installed MongoDB 2.6 and I am trying to run it as a Windows Service on Windows 8, by following the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/.



Here's my directory structure within the C drive:





  • MongoDB (MongoDB installation)

    • bin




  • Project

    • DB

    • Log

    • mongo.conf

    • mongod.cfg




The contents of mongo.conf is:



storage:
dbPath: "C:ProjectDB"


And the contents of mongod.cfg is:



logpath="C:ProjectLogmongo.log" 


As directed to in the tutorial, from the command line (in administrator mode) I then type:



"C:MongoDBbinmongod.exe" --config "C:Projectmongod.cfg" --install



However, I get an error message:



SEVERE: Failed global initialization: FileNotOpen Failed to open ""C:MongoDBbinProjectLogmongo.log""



Please can somebody explain what I'm doing wrong? I've followed the instructions as dictated in the tutorial (except changed some of the directory names).



I'm also very confused as to the difference between mongo.conf and mongod.cfg...



Thanks!










share|improve this question



























    16















    I have just installed MongoDB 2.6 and I am trying to run it as a Windows Service on Windows 8, by following the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/.



    Here's my directory structure within the C drive:





    • MongoDB (MongoDB installation)

      • bin




    • Project

      • DB

      • Log

      • mongo.conf

      • mongod.cfg




    The contents of mongo.conf is:



    storage:
    dbPath: "C:ProjectDB"


    And the contents of mongod.cfg is:



    logpath="C:ProjectLogmongo.log" 


    As directed to in the tutorial, from the command line (in administrator mode) I then type:



    "C:MongoDBbinmongod.exe" --config "C:Projectmongod.cfg" --install



    However, I get an error message:



    SEVERE: Failed global initialization: FileNotOpen Failed to open ""C:MongoDBbinProjectLogmongo.log""



    Please can somebody explain what I'm doing wrong? I've followed the instructions as dictated in the tutorial (except changed some of the directory names).



    I'm also very confused as to the difference between mongo.conf and mongod.cfg...



    Thanks!










    share|improve this question

























      16












      16








      16


      6






      I have just installed MongoDB 2.6 and I am trying to run it as a Windows Service on Windows 8, by following the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/.



      Here's my directory structure within the C drive:





      • MongoDB (MongoDB installation)

        • bin




      • Project

        • DB

        • Log

        • mongo.conf

        • mongod.cfg




      The contents of mongo.conf is:



      storage:
      dbPath: "C:ProjectDB"


      And the contents of mongod.cfg is:



      logpath="C:ProjectLogmongo.log" 


      As directed to in the tutorial, from the command line (in administrator mode) I then type:



      "C:MongoDBbinmongod.exe" --config "C:Projectmongod.cfg" --install



      However, I get an error message:



      SEVERE: Failed global initialization: FileNotOpen Failed to open ""C:MongoDBbinProjectLogmongo.log""



      Please can somebody explain what I'm doing wrong? I've followed the instructions as dictated in the tutorial (except changed some of the directory names).



      I'm also very confused as to the difference between mongo.conf and mongod.cfg...



      Thanks!










      share|improve this question














      I have just installed MongoDB 2.6 and I am trying to run it as a Windows Service on Windows 8, by following the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/.



      Here's my directory structure within the C drive:





      • MongoDB (MongoDB installation)

        • bin




      • Project

        • DB

        • Log

        • mongo.conf

        • mongod.cfg




      The contents of mongo.conf is:



      storage:
      dbPath: "C:ProjectDB"


      And the contents of mongod.cfg is:



      logpath="C:ProjectLogmongo.log" 


      As directed to in the tutorial, from the command line (in administrator mode) I then type:



      "C:MongoDBbinmongod.exe" --config "C:Projectmongod.cfg" --install



      However, I get an error message:



      SEVERE: Failed global initialization: FileNotOpen Failed to open ""C:MongoDBbinProjectLogmongo.log""



      Please can somebody explain what I'm doing wrong? I've followed the instructions as dictated in the tutorial (except changed some of the directory names).



      I'm also very confused as to the difference between mongo.conf and mongod.cfg...



      Thanks!







      mongodb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 15 '14 at 22:40









      KarnivaurusKarnivaurus

      5,7013088160




      5,7013088160
























          10 Answers
          10






          active

          oldest

          votes


















          27














          I was having a similar problem with Mongo 2.6.3. I was trying to set the log path to C:UsersPublicPublic DatabasesMongologmongo.log and the service installer kept responding with Failed to open ""C:Program FilesMongoDB 2.6 StandardbinUsersPublicPublic
          DatabasesMongologmongo.log""
          .



          It started working for me when I stopped quoting the log path in the config file. (i.e. I changed logpath="C:UsersPublicPublic DatabasesMongologmongo.log" to logpath=C:UsersPublicPublic DatabasesMongologmongo.log).






          share|improve this answer
























          • Fixed it for me too.

            – Simon
            Jul 16 '14 at 19:31











          • Yes, this worked. Thanks

            – qais
            Aug 11 '14 at 11:07











          • Importantly, be sure to run the command prompt with Administrator privileges. This fixed it for me. I use version Mongo 3.4

            – Komoo
            Jul 7 '17 at 11:57



















          3














          There is a known issue installing MongoDB 2.6.0 as a Windows service using the --install command - see SERVER-13515. A fix has been committed for the MongoDB 2.6.1 release.



          As a workaround,
          I've provided instructions on how to install the service manually on that SERVER issue.



          The short version is:




          • open an Administrator cmd prompt

          • make directories for your database and log files

          • create a configuration file


          • create the service definition, similar to:



            sc create MongoDB binPath= ""C:Program FilesMongoDB 2.6 Standardbinmongod.exe" --service --config="C:Program FilesMongoDB 2.6 Standardmongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"



          • start the MongoDB service



            net start MongoDB



          For full instructions please refer to SERVER-13515.




          I'm also very confused as to the difference between mongo.conf and mongod.cfg




          The MongoDB server doesn't care about the name/extension of the file you specify with --config (as long as the file can be read). Your confusion on the format is because the mongo.conf example uses the new YAML config file format supported by MongoDB 2.6+, while mongod.cfg uses the older format supported by 2.6 as well as earlier versions.



          I used the older mongod.cfg format in my workaround example, as technically someone could adapt these instructions to manually create a service definition for MongoDB 2.4 as well.






          share|improve this answer































            2














            I got the same problem not only when installing as a Windows service but also when running "mongodb.exe" file. I tried to remove double quote (") characters but the error was still there:



            2014-08-16T14:14:49.166Z SEVERE: Failed global initialization: FileNotOpen Failed to open "D:MongoDBlogmongo.log"



            Please note that I was using config file in new YAML format. I had no problem when using the old format. I tried several ways on the new YAML configuration file and finally I found that it doesn't accept the absolute path. Just change to relative path and it works like a charm!



            My folder structure is:
            MongoDB
            bin
            data
            log


            Here is my YAML configuration file that works on the build MongoDB 2.6.4 - Windows 64 bit version, installed on my Windows 7 - Professional x64:



            systemLog:
            timeStampFormat: iso8601-utc
            destination: file
            path: ..logmongo.log
            quiet: false
            logAppend: true
            net:
            bindIp: 127.0.0.1
            port: 27017
            storage:
            dbPath: ..data
            directoryPerDB: true
            journal:
            enabled: true





            share|improve this answer
























            • Just for the record: While a path with ".." or starting with "" works when run from the prompt, they are broken when run as a service. This mistake took some time to debug because it was not being logged (what found the error was running "mongod.exe --config c:mongodbmongodb.conf --service" by hand).

              – Lucas Soares
              Feb 9 '15 at 14:53





















            1














            I tried a lot of things, in the end I had to remove config file and pass dbpath and logpath settings directly. Following command worked for me:-



            C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --instal
            l --serviceName MongoDB --serviceDisplayName MongoDB






            share|improve this answer



















            • 1





              C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --install --serviceName MongoDB --serviceDisplayName MongoDB

              – Umer Chohan
              Jun 17 '15 at 22:36



















            0














            There is a JIRA on that topic for the last version of MongoDB and a workaround too. A solution is to install a previous version then install the service ans re-use the last version of the driver.
            Hope this helps !






            share|improve this answer
























            • Can you link to the Jira ticket?

              – Underverse
              Jan 1 at 4:38



















            0














            @Stennie 's answer, as well as the manual service installation instructions on the mongoDB site were adequate for me. One thing to note though, is that the quoted items in the instructions need double backslashes (\) in order to work correctly. Probably obvious to most developers, but I had it slip my mind, and the error response was simply that the service fails to start up. Also, be wary of the spaces after the equals signs.



            sc.exe create MongoDB binPath= ""C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --service --config="C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"





            share|improve this answer































              0














              Observing your error log, it's passing two "s instead of one. Omit one(edit your config file content and remove "s) and you should be good.






              share|improve this answer































                0














                Sometimes when you have error like : "Failed global initialization: FileNotOpen Failed to open .../mongodb.log", if you have log file you can delete it and try again.






                share|improve this answer































                  0














                  Stop MongoDB from Windows Services and then try again. It worked for me!






                  share|improve this answer































                    0














                    My previous logpath=c:programfiles......
                    the alternative is logpath="c:program files......"
                    it works



                    I think the reason is that the system must visit the log file through c:program files......, but there comes error when I write logpath=c:program files......because there is a space between program and files. Then I add "", and it works. I hope it helps.






                    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%2f23095845%2fmongodb-setting-up-windows-service%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown

























                      10 Answers
                      10






                      active

                      oldest

                      votes








                      10 Answers
                      10






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      27














                      I was having a similar problem with Mongo 2.6.3. I was trying to set the log path to C:UsersPublicPublic DatabasesMongologmongo.log and the service installer kept responding with Failed to open ""C:Program FilesMongoDB 2.6 StandardbinUsersPublicPublic
                      DatabasesMongologmongo.log""
                      .



                      It started working for me when I stopped quoting the log path in the config file. (i.e. I changed logpath="C:UsersPublicPublic DatabasesMongologmongo.log" to logpath=C:UsersPublicPublic DatabasesMongologmongo.log).






                      share|improve this answer
























                      • Fixed it for me too.

                        – Simon
                        Jul 16 '14 at 19:31











                      • Yes, this worked. Thanks

                        – qais
                        Aug 11 '14 at 11:07











                      • Importantly, be sure to run the command prompt with Administrator privileges. This fixed it for me. I use version Mongo 3.4

                        – Komoo
                        Jul 7 '17 at 11:57
















                      27














                      I was having a similar problem with Mongo 2.6.3. I was trying to set the log path to C:UsersPublicPublic DatabasesMongologmongo.log and the service installer kept responding with Failed to open ""C:Program FilesMongoDB 2.6 StandardbinUsersPublicPublic
                      DatabasesMongologmongo.log""
                      .



                      It started working for me when I stopped quoting the log path in the config file. (i.e. I changed logpath="C:UsersPublicPublic DatabasesMongologmongo.log" to logpath=C:UsersPublicPublic DatabasesMongologmongo.log).






                      share|improve this answer
























                      • Fixed it for me too.

                        – Simon
                        Jul 16 '14 at 19:31











                      • Yes, this worked. Thanks

                        – qais
                        Aug 11 '14 at 11:07











                      • Importantly, be sure to run the command prompt with Administrator privileges. This fixed it for me. I use version Mongo 3.4

                        – Komoo
                        Jul 7 '17 at 11:57














                      27












                      27








                      27







                      I was having a similar problem with Mongo 2.6.3. I was trying to set the log path to C:UsersPublicPublic DatabasesMongologmongo.log and the service installer kept responding with Failed to open ""C:Program FilesMongoDB 2.6 StandardbinUsersPublicPublic
                      DatabasesMongologmongo.log""
                      .



                      It started working for me when I stopped quoting the log path in the config file. (i.e. I changed logpath="C:UsersPublicPublic DatabasesMongologmongo.log" to logpath=C:UsersPublicPublic DatabasesMongologmongo.log).






                      share|improve this answer













                      I was having a similar problem with Mongo 2.6.3. I was trying to set the log path to C:UsersPublicPublic DatabasesMongologmongo.log and the service installer kept responding with Failed to open ""C:Program FilesMongoDB 2.6 StandardbinUsersPublicPublic
                      DatabasesMongologmongo.log""
                      .



                      It started working for me when I stopped quoting the log path in the config file. (i.e. I changed logpath="C:UsersPublicPublic DatabasesMongologmongo.log" to logpath=C:UsersPublicPublic DatabasesMongologmongo.log).







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jul 3 '14 at 5:43









                      Tristan WilkinsonTristan Wilkinson

                      65968




                      65968













                      • Fixed it for me too.

                        – Simon
                        Jul 16 '14 at 19:31











                      • Yes, this worked. Thanks

                        – qais
                        Aug 11 '14 at 11:07











                      • Importantly, be sure to run the command prompt with Administrator privileges. This fixed it for me. I use version Mongo 3.4

                        – Komoo
                        Jul 7 '17 at 11:57



















                      • Fixed it for me too.

                        – Simon
                        Jul 16 '14 at 19:31











                      • Yes, this worked. Thanks

                        – qais
                        Aug 11 '14 at 11:07











                      • Importantly, be sure to run the command prompt with Administrator privileges. This fixed it for me. I use version Mongo 3.4

                        – Komoo
                        Jul 7 '17 at 11:57

















                      Fixed it for me too.

                      – Simon
                      Jul 16 '14 at 19:31





                      Fixed it for me too.

                      – Simon
                      Jul 16 '14 at 19:31













                      Yes, this worked. Thanks

                      – qais
                      Aug 11 '14 at 11:07





                      Yes, this worked. Thanks

                      – qais
                      Aug 11 '14 at 11:07













                      Importantly, be sure to run the command prompt with Administrator privileges. This fixed it for me. I use version Mongo 3.4

                      – Komoo
                      Jul 7 '17 at 11:57





                      Importantly, be sure to run the command prompt with Administrator privileges. This fixed it for me. I use version Mongo 3.4

                      – Komoo
                      Jul 7 '17 at 11:57













                      3














                      There is a known issue installing MongoDB 2.6.0 as a Windows service using the --install command - see SERVER-13515. A fix has been committed for the MongoDB 2.6.1 release.



                      As a workaround,
                      I've provided instructions on how to install the service manually on that SERVER issue.



                      The short version is:




                      • open an Administrator cmd prompt

                      • make directories for your database and log files

                      • create a configuration file


                      • create the service definition, similar to:



                        sc create MongoDB binPath= ""C:Program FilesMongoDB 2.6 Standardbinmongod.exe" --service --config="C:Program FilesMongoDB 2.6 Standardmongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"



                      • start the MongoDB service



                        net start MongoDB



                      For full instructions please refer to SERVER-13515.




                      I'm also very confused as to the difference between mongo.conf and mongod.cfg




                      The MongoDB server doesn't care about the name/extension of the file you specify with --config (as long as the file can be read). Your confusion on the format is because the mongo.conf example uses the new YAML config file format supported by MongoDB 2.6+, while mongod.cfg uses the older format supported by 2.6 as well as earlier versions.



                      I used the older mongod.cfg format in my workaround example, as technically someone could adapt these instructions to manually create a service definition for MongoDB 2.4 as well.






                      share|improve this answer




























                        3














                        There is a known issue installing MongoDB 2.6.0 as a Windows service using the --install command - see SERVER-13515. A fix has been committed for the MongoDB 2.6.1 release.



                        As a workaround,
                        I've provided instructions on how to install the service manually on that SERVER issue.



                        The short version is:




                        • open an Administrator cmd prompt

                        • make directories for your database and log files

                        • create a configuration file


                        • create the service definition, similar to:



                          sc create MongoDB binPath= ""C:Program FilesMongoDB 2.6 Standardbinmongod.exe" --service --config="C:Program FilesMongoDB 2.6 Standardmongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"



                        • start the MongoDB service



                          net start MongoDB



                        For full instructions please refer to SERVER-13515.




                        I'm also very confused as to the difference between mongo.conf and mongod.cfg




                        The MongoDB server doesn't care about the name/extension of the file you specify with --config (as long as the file can be read). Your confusion on the format is because the mongo.conf example uses the new YAML config file format supported by MongoDB 2.6+, while mongod.cfg uses the older format supported by 2.6 as well as earlier versions.



                        I used the older mongod.cfg format in my workaround example, as technically someone could adapt these instructions to manually create a service definition for MongoDB 2.4 as well.






                        share|improve this answer


























                          3












                          3








                          3







                          There is a known issue installing MongoDB 2.6.0 as a Windows service using the --install command - see SERVER-13515. A fix has been committed for the MongoDB 2.6.1 release.



                          As a workaround,
                          I've provided instructions on how to install the service manually on that SERVER issue.



                          The short version is:




                          • open an Administrator cmd prompt

                          • make directories for your database and log files

                          • create a configuration file


                          • create the service definition, similar to:



                            sc create MongoDB binPath= ""C:Program FilesMongoDB 2.6 Standardbinmongod.exe" --service --config="C:Program FilesMongoDB 2.6 Standardmongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"



                          • start the MongoDB service



                            net start MongoDB



                          For full instructions please refer to SERVER-13515.




                          I'm also very confused as to the difference between mongo.conf and mongod.cfg




                          The MongoDB server doesn't care about the name/extension of the file you specify with --config (as long as the file can be read). Your confusion on the format is because the mongo.conf example uses the new YAML config file format supported by MongoDB 2.6+, while mongod.cfg uses the older format supported by 2.6 as well as earlier versions.



                          I used the older mongod.cfg format in my workaround example, as technically someone could adapt these instructions to manually create a service definition for MongoDB 2.4 as well.






                          share|improve this answer













                          There is a known issue installing MongoDB 2.6.0 as a Windows service using the --install command - see SERVER-13515. A fix has been committed for the MongoDB 2.6.1 release.



                          As a workaround,
                          I've provided instructions on how to install the service manually on that SERVER issue.



                          The short version is:




                          • open an Administrator cmd prompt

                          • make directories for your database and log files

                          • create a configuration file


                          • create the service definition, similar to:



                            sc create MongoDB binPath= ""C:Program FilesMongoDB 2.6 Standardbinmongod.exe" --service --config="C:Program FilesMongoDB 2.6 Standardmongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"



                          • start the MongoDB service



                            net start MongoDB



                          For full instructions please refer to SERVER-13515.




                          I'm also very confused as to the difference between mongo.conf and mongod.cfg




                          The MongoDB server doesn't care about the name/extension of the file you specify with --config (as long as the file can be read). Your confusion on the format is because the mongo.conf example uses the new YAML config file format supported by MongoDB 2.6+, while mongod.cfg uses the older format supported by 2.6 as well as earlier versions.



                          I used the older mongod.cfg format in my workaround example, as technically someone could adapt these instructions to manually create a service definition for MongoDB 2.4 as well.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 16 '14 at 0:48









                          StennieStennie

                          47.1k8110139




                          47.1k8110139























                              2














                              I got the same problem not only when installing as a Windows service but also when running "mongodb.exe" file. I tried to remove double quote (") characters but the error was still there:



                              2014-08-16T14:14:49.166Z SEVERE: Failed global initialization: FileNotOpen Failed to open "D:MongoDBlogmongo.log"



                              Please note that I was using config file in new YAML format. I had no problem when using the old format. I tried several ways on the new YAML configuration file and finally I found that it doesn't accept the absolute path. Just change to relative path and it works like a charm!



                              My folder structure is:
                              MongoDB
                              bin
                              data
                              log


                              Here is my YAML configuration file that works on the build MongoDB 2.6.4 - Windows 64 bit version, installed on my Windows 7 - Professional x64:



                              systemLog:
                              timeStampFormat: iso8601-utc
                              destination: file
                              path: ..logmongo.log
                              quiet: false
                              logAppend: true
                              net:
                              bindIp: 127.0.0.1
                              port: 27017
                              storage:
                              dbPath: ..data
                              directoryPerDB: true
                              journal:
                              enabled: true





                              share|improve this answer
























                              • Just for the record: While a path with ".." or starting with "" works when run from the prompt, they are broken when run as a service. This mistake took some time to debug because it was not being logged (what found the error was running "mongod.exe --config c:mongodbmongodb.conf --service" by hand).

                                – Lucas Soares
                                Feb 9 '15 at 14:53


















                              2














                              I got the same problem not only when installing as a Windows service but also when running "mongodb.exe" file. I tried to remove double quote (") characters but the error was still there:



                              2014-08-16T14:14:49.166Z SEVERE: Failed global initialization: FileNotOpen Failed to open "D:MongoDBlogmongo.log"



                              Please note that I was using config file in new YAML format. I had no problem when using the old format. I tried several ways on the new YAML configuration file and finally I found that it doesn't accept the absolute path. Just change to relative path and it works like a charm!



                              My folder structure is:
                              MongoDB
                              bin
                              data
                              log


                              Here is my YAML configuration file that works on the build MongoDB 2.6.4 - Windows 64 bit version, installed on my Windows 7 - Professional x64:



                              systemLog:
                              timeStampFormat: iso8601-utc
                              destination: file
                              path: ..logmongo.log
                              quiet: false
                              logAppend: true
                              net:
                              bindIp: 127.0.0.1
                              port: 27017
                              storage:
                              dbPath: ..data
                              directoryPerDB: true
                              journal:
                              enabled: true





                              share|improve this answer
























                              • Just for the record: While a path with ".." or starting with "" works when run from the prompt, they are broken when run as a service. This mistake took some time to debug because it was not being logged (what found the error was running "mongod.exe --config c:mongodbmongodb.conf --service" by hand).

                                – Lucas Soares
                                Feb 9 '15 at 14:53
















                              2












                              2








                              2







                              I got the same problem not only when installing as a Windows service but also when running "mongodb.exe" file. I tried to remove double quote (") characters but the error was still there:



                              2014-08-16T14:14:49.166Z SEVERE: Failed global initialization: FileNotOpen Failed to open "D:MongoDBlogmongo.log"



                              Please note that I was using config file in new YAML format. I had no problem when using the old format. I tried several ways on the new YAML configuration file and finally I found that it doesn't accept the absolute path. Just change to relative path and it works like a charm!



                              My folder structure is:
                              MongoDB
                              bin
                              data
                              log


                              Here is my YAML configuration file that works on the build MongoDB 2.6.4 - Windows 64 bit version, installed on my Windows 7 - Professional x64:



                              systemLog:
                              timeStampFormat: iso8601-utc
                              destination: file
                              path: ..logmongo.log
                              quiet: false
                              logAppend: true
                              net:
                              bindIp: 127.0.0.1
                              port: 27017
                              storage:
                              dbPath: ..data
                              directoryPerDB: true
                              journal:
                              enabled: true





                              share|improve this answer













                              I got the same problem not only when installing as a Windows service but also when running "mongodb.exe" file. I tried to remove double quote (") characters but the error was still there:



                              2014-08-16T14:14:49.166Z SEVERE: Failed global initialization: FileNotOpen Failed to open "D:MongoDBlogmongo.log"



                              Please note that I was using config file in new YAML format. I had no problem when using the old format. I tried several ways on the new YAML configuration file and finally I found that it doesn't accept the absolute path. Just change to relative path and it works like a charm!



                              My folder structure is:
                              MongoDB
                              bin
                              data
                              log


                              Here is my YAML configuration file that works on the build MongoDB 2.6.4 - Windows 64 bit version, installed on my Windows 7 - Professional x64:



                              systemLog:
                              timeStampFormat: iso8601-utc
                              destination: file
                              path: ..logmongo.log
                              quiet: false
                              logAppend: true
                              net:
                              bindIp: 127.0.0.1
                              port: 27017
                              storage:
                              dbPath: ..data
                              directoryPerDB: true
                              journal:
                              enabled: true






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Aug 16 '14 at 14:49









                              Thach VanThach Van

                              68588




                              68588













                              • Just for the record: While a path with ".." or starting with "" works when run from the prompt, they are broken when run as a service. This mistake took some time to debug because it was not being logged (what found the error was running "mongod.exe --config c:mongodbmongodb.conf --service" by hand).

                                – Lucas Soares
                                Feb 9 '15 at 14:53





















                              • Just for the record: While a path with ".." or starting with "" works when run from the prompt, they are broken when run as a service. This mistake took some time to debug because it was not being logged (what found the error was running "mongod.exe --config c:mongodbmongodb.conf --service" by hand).

                                – Lucas Soares
                                Feb 9 '15 at 14:53



















                              Just for the record: While a path with ".." or starting with "" works when run from the prompt, they are broken when run as a service. This mistake took some time to debug because it was not being logged (what found the error was running "mongod.exe --config c:mongodbmongodb.conf --service" by hand).

                              – Lucas Soares
                              Feb 9 '15 at 14:53







                              Just for the record: While a path with ".." or starting with "" works when run from the prompt, they are broken when run as a service. This mistake took some time to debug because it was not being logged (what found the error was running "mongod.exe --config c:mongodbmongodb.conf --service" by hand).

                              – Lucas Soares
                              Feb 9 '15 at 14:53













                              1














                              I tried a lot of things, in the end I had to remove config file and pass dbpath and logpath settings directly. Following command worked for me:-



                              C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --instal
                              l --serviceName MongoDB --serviceDisplayName MongoDB






                              share|improve this answer



















                              • 1





                                C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --install --serviceName MongoDB --serviceDisplayName MongoDB

                                – Umer Chohan
                                Jun 17 '15 at 22:36
















                              1














                              I tried a lot of things, in the end I had to remove config file and pass dbpath and logpath settings directly. Following command worked for me:-



                              C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --instal
                              l --serviceName MongoDB --serviceDisplayName MongoDB






                              share|improve this answer



















                              • 1





                                C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --install --serviceName MongoDB --serviceDisplayName MongoDB

                                – Umer Chohan
                                Jun 17 '15 at 22:36














                              1












                              1








                              1







                              I tried a lot of things, in the end I had to remove config file and pass dbpath and logpath settings directly. Following command worked for me:-



                              C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --instal
                              l --serviceName MongoDB --serviceDisplayName MongoDB






                              share|improve this answer













                              I tried a lot of things, in the end I had to remove config file and pass dbpath and logpath settings directly. Following command worked for me:-



                              C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --instal
                              l --serviceName MongoDB --serviceDisplayName MongoDB







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 8 '14 at 23:26









                              Umer ChohanUmer Chohan

                              313




                              313








                              • 1





                                C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --install --serviceName MongoDB --serviceDisplayName MongoDB

                                – Umer Chohan
                                Jun 17 '15 at 22:36














                              • 1





                                C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --install --serviceName MongoDB --serviceDisplayName MongoDB

                                – Umer Chohan
                                Jun 17 '15 at 22:36








                              1




                              1





                              C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --install --serviceName MongoDB --serviceDisplayName MongoDB

                              – Umer Chohan
                              Jun 17 '15 at 22:36





                              C:>mongod --dbpath d:mongodbdata --logpath d:mongodblogsmongo.log --install --serviceName MongoDB --serviceDisplayName MongoDB

                              – Umer Chohan
                              Jun 17 '15 at 22:36











                              0














                              There is a JIRA on that topic for the last version of MongoDB and a workaround too. A solution is to install a previous version then install the service ans re-use the last version of the driver.
                              Hope this helps !






                              share|improve this answer
























                              • Can you link to the Jira ticket?

                                – Underverse
                                Jan 1 at 4:38
















                              0














                              There is a JIRA on that topic for the last version of MongoDB and a workaround too. A solution is to install a previous version then install the service ans re-use the last version of the driver.
                              Hope this helps !






                              share|improve this answer
























                              • Can you link to the Jira ticket?

                                – Underverse
                                Jan 1 at 4:38














                              0












                              0








                              0







                              There is a JIRA on that topic for the last version of MongoDB and a workaround too. A solution is to install a previous version then install the service ans re-use the last version of the driver.
                              Hope this helps !






                              share|improve this answer













                              There is a JIRA on that topic for the last version of MongoDB and a workaround too. A solution is to install a previous version then install the service ans re-use the last version of the driver.
                              Hope this helps !







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Apr 16 '14 at 0:04









                              GuillaumeAGuillaumeA

                              2,07432239




                              2,07432239













                              • Can you link to the Jira ticket?

                                – Underverse
                                Jan 1 at 4:38



















                              • Can you link to the Jira ticket?

                                – Underverse
                                Jan 1 at 4:38

















                              Can you link to the Jira ticket?

                              – Underverse
                              Jan 1 at 4:38





                              Can you link to the Jira ticket?

                              – Underverse
                              Jan 1 at 4:38











                              0














                              @Stennie 's answer, as well as the manual service installation instructions on the mongoDB site were adequate for me. One thing to note though, is that the quoted items in the instructions need double backslashes (\) in order to work correctly. Probably obvious to most developers, but I had it slip my mind, and the error response was simply that the service fails to start up. Also, be wary of the spaces after the equals signs.



                              sc.exe create MongoDB binPath= ""C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --service --config="C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"





                              share|improve this answer




























                                0














                                @Stennie 's answer, as well as the manual service installation instructions on the mongoDB site were adequate for me. One thing to note though, is that the quoted items in the instructions need double backslashes (\) in order to work correctly. Probably obvious to most developers, but I had it slip my mind, and the error response was simply that the service fails to start up. Also, be wary of the spaces after the equals signs.



                                sc.exe create MongoDB binPath= ""C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --service --config="C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"





                                share|improve this answer


























                                  0












                                  0








                                  0







                                  @Stennie 's answer, as well as the manual service installation instructions on the mongoDB site were adequate for me. One thing to note though, is that the quoted items in the instructions need double backslashes (\) in order to work correctly. Probably obvious to most developers, but I had it slip my mind, and the error response was simply that the service fails to start up. Also, be wary of the spaces after the equals signs.



                                  sc.exe create MongoDB binPath= ""C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --service --config="C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"





                                  share|improve this answer













                                  @Stennie 's answer, as well as the manual service installation instructions on the mongoDB site were adequate for me. One thing to note though, is that the quoted items in the instructions need double backslashes (\) in order to work correctly. Probably obvious to most developers, but I had it slip my mind, and the error response was simply that the service fails to start up. Also, be wary of the spaces after the equals signs.



                                  sc.exe create MongoDB binPath= ""C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe" --service --config="C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"" DisplayName= "MongoDB 2.6 Standard" start= "auto"






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Jul 2 '14 at 1:30









                                  chenj7chenj7

                                  5517




                                  5517























                                      0














                                      Observing your error log, it's passing two "s instead of one. Omit one(edit your config file content and remove "s) and you should be good.






                                      share|improve this answer




























                                        0














                                        Observing your error log, it's passing two "s instead of one. Omit one(edit your config file content and remove "s) and you should be good.






                                        share|improve this answer


























                                          0












                                          0








                                          0







                                          Observing your error log, it's passing two "s instead of one. Omit one(edit your config file content and remove "s) and you should be good.






                                          share|improve this answer













                                          Observing your error log, it's passing two "s instead of one. Omit one(edit your config file content and remove "s) and you should be good.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Sep 1 '14 at 11:01









                                          mapmap

                                          14414




                                          14414























                                              0














                                              Sometimes when you have error like : "Failed global initialization: FileNotOpen Failed to open .../mongodb.log", if you have log file you can delete it and try again.






                                              share|improve this answer




























                                                0














                                                Sometimes when you have error like : "Failed global initialization: FileNotOpen Failed to open .../mongodb.log", if you have log file you can delete it and try again.






                                                share|improve this answer


























                                                  0












                                                  0








                                                  0







                                                  Sometimes when you have error like : "Failed global initialization: FileNotOpen Failed to open .../mongodb.log", if you have log file you can delete it and try again.






                                                  share|improve this answer













                                                  Sometimes when you have error like : "Failed global initialization: FileNotOpen Failed to open .../mongodb.log", if you have log file you can delete it and try again.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Mar 23 '15 at 22:11









                                                  Eran OrEran Or

                                                  323514




                                                  323514























                                                      0














                                                      Stop MongoDB from Windows Services and then try again. It worked for me!






                                                      share|improve this answer




























                                                        0














                                                        Stop MongoDB from Windows Services and then try again. It worked for me!






                                                        share|improve this answer


























                                                          0












                                                          0








                                                          0







                                                          Stop MongoDB from Windows Services and then try again. It worked for me!






                                                          share|improve this answer













                                                          Stop MongoDB from Windows Services and then try again. It worked for me!







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Jan 15 '18 at 7:39









                                                          TatkalTatkal

                                                          581417




                                                          581417























                                                              0














                                                              My previous logpath=c:programfiles......
                                                              the alternative is logpath="c:program files......"
                                                              it works



                                                              I think the reason is that the system must visit the log file through c:program files......, but there comes error when I write logpath=c:program files......because there is a space between program and files. Then I add "", and it works. I hope it helps.






                                                              share|improve this answer






























                                                                0














                                                                My previous logpath=c:programfiles......
                                                                the alternative is logpath="c:program files......"
                                                                it works



                                                                I think the reason is that the system must visit the log file through c:program files......, but there comes error when I write logpath=c:program files......because there is a space between program and files. Then I add "", and it works. I hope it helps.






                                                                share|improve this answer




























                                                                  0












                                                                  0








                                                                  0







                                                                  My previous logpath=c:programfiles......
                                                                  the alternative is logpath="c:program files......"
                                                                  it works



                                                                  I think the reason is that the system must visit the log file through c:program files......, but there comes error when I write logpath=c:program files......because there is a space between program and files. Then I add "", and it works. I hope it helps.






                                                                  share|improve this answer















                                                                  My previous logpath=c:programfiles......
                                                                  the alternative is logpath="c:program files......"
                                                                  it works



                                                                  I think the reason is that the system must visit the log file through c:program files......, but there comes error when I write logpath=c:program files......because there is a space between program and files. Then I add "", and it works. I hope it helps.







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited Jan 1 at 4:48









                                                                  halfelf

                                                                  6,681103249




                                                                  6,681103249










                                                                  answered Jan 1 at 4:27









                                                                  刘乐平刘乐平

                                                                  1




                                                                  1






























                                                                      draft saved

                                                                      draft discarded




















































                                                                      Thanks for contributing an answer to Stack Overflow!


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

                                                                      But avoid



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

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


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




                                                                      draft saved


                                                                      draft discarded














                                                                      StackExchange.ready(
                                                                      function () {
                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23095845%2fmongodb-setting-up-windows-service%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

                                                                      MongoDB - Not Authorized To Execute Command

                                                                      in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

                                                                      How to fix TextFormField cause rebuild widget in Flutter