mongod command not recognized when trying to connect to a mongodb server

后端 未结 14 626
暖寄归人
暖寄归人 2021-01-31 01:11

I am following the tutorials at docs.mongodb.org, I have completed the first tutorial which was to install mongodb on a windows machine. I am now at the second stage which is ge

相关标签:
14条回答
  • 2021-01-31 01:55

    Apart from having a Path variable, the directory C:\data\db is mandatory.

    Create this and the error shall be solved.

    0 讨论(0)
  • 2021-01-31 01:57

    This worked for me: .\mongod --dbpath c:......

    0 讨论(0)
  • 2021-01-31 01:57

    First, make sure you have the environment variable set up. 1. Right click on my computer 2. properties 3. advanced system settings 4. environment variables 5. edit the PATH variable. and add ;"C:\mongoDb\bin\" to the PATH variable.

    Path in the quotes may differ depending on your installation directory. Do not forget the last '\' as it was the main problem in my case.

    0 讨论(0)
  • 2021-01-31 02:03

    For add environment variable please add \ after bin like below

    C:\Program Files\MongoDB\Server\3.2\bin\
    

    Then try below code in command prompt to run mongo server from parent folder of data folder.

    mongod -dbpath ./data
    

    For my case I am unable to run mongo from command prompt(normal mode). You should run as administrator. It also works on git bash.

    0 讨论(0)
  • 2021-01-31 02:04

    It is probably too late, but for the sake of others (like me) who faced the same problem. It is all about the little '\' at the end of the path variable. When you insert the path to MongoDB's bin directory at the end of the PATH windows variable, do not forget to put the '\' (Backslash) at the end, which tells windows it is a directory and not an executable named bin... e.g. I:\Program Files\MongoDB\Server\3.0\bin\

    0 讨论(0)
  • 2021-01-31 02:06

    1.To begin using MongoDB, Open CMD with admin privilege and type : "C:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"

    2.To create data directory(open another cmd terminal) cd C:
    md "\data\db" 3. To start your mongo DB database, type in cmd the following lines: "C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe" --dbpath="c:\data\db" (The --dbpath option points to your database directory.) [you can also do step 2 and 3 first and then step 1]

    ref:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

    0 讨论(0)
提交回复
热议问题