Configuring MongoDB on Windows

后端 未结 6 679
耶瑟儿~
耶瑟儿~ 2021-02-08 10:49

I am trying to set up MongoDB on Windows, and the online docs seem far from accurate.

Under \"Configure a Windows Service\" part, step 1 mentions to create a config file

相关标签:
6条回答
  • 2021-02-08 11:12

    For those who installed via *.msi installer and wondering where is .conf file located. Run 'services.msc' and check properties of mongodb service runnable file.

    0 讨论(0)
  • 2021-02-08 11:14

    Here is my simple test MongoDB Config file for Windows. Note that I had to have 2 spaces before each property, e.g., path. When I had 3 spaces I got an error at startup.

    I start the server with: mongod --config c:\tools\mongodb\db\mongod.cfg

    systemLog:
      destination: file
      path: "C:\\tools\\mongodb\\db\\log\\mongo.log"
      logAppend: true
    storage:
      dbPath: "C:\\tools\\mongodb\\db\\data"
    security:
      authorization: enabled
    
    0 讨论(0)
  • 2021-02-08 11:19

    You can find logs with reasons why it's not working in log file. In your case, read P:\Servers\MongoDB\logs\mongodb.log file.

    0 讨论(0)
  • 2021-02-08 11:23

    Here's an example of a mongodb.config file for Windows.

    ##store data here
    dbpath=C:\mongodb\data\db
    
    ##all output go here
    logpath=C:\mongodb\data\log\mongo.log
    
    ##log read and write operations
    diaglog=3
    
    0 讨论(0)
  • 2021-02-08 11:24

    check if you have any file in data\db path. Please remove all those files and try to restart. I exactly used your config file and able to start the service successfully with bindip and port

    0 讨论(0)
  • 2021-02-08 11:25

    Bit late but I had the exact same issue today. If you use forward slashes for your paths within the config file it works fine.

    systemLog: destination: file logAppend: true path: "e:/mongo_data/3.6/mongo.log" storage: dbPath: "e:/mongo_data/3.6/db" engine: "wiredTiger"

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