How do I start Mongo DB from Windows?

2019-01-12 15:21发布

I have installed MongoDB on my Window 7(64 bit) machine. I have created the path data/db too but when I tried to start mongodb using the command 'C:\mongodb\bin\mongod.exe', it is not starting. It is showing admin web console waiting for connections on port 28017. Help me in getting start the MongoDB. And also please suggest if any GUI available for MongoDB. Thanks in advance.

13条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-12 15:56

Actually windows way to use service, from the official documentation:

  • Find out where is your executable is installed, path may be like this:

    "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"

  • Create config file with such content (yaml format), path may be like this:

    "C:\Program Files\MongoDB\Server\3.4\mongod.cfg"

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db
  • Execute as admin the next command (run command line as admin):
C:\...\mongod.exe --config C:\...\mongod.cfg --install

Where paths is reduced with dots, see above.

The key --install say to mongo to install itself as windows service.

Now you can start, stop, restart mongo server as usual windows service choose your favorite way from this:

  • from Control Panel -> Administration -> Services -> MongoDB
  • by command execution from command line as admin: (net start MongoDB)

Check log file specified in config file if any problems.

查看更多
孤傲高冷的网名
3楼-- · 2019-01-12 16:00

Step 1

Download the mongodb

Step 2

  • Follow normal setup instructions

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Step 3

  • Create the following folder

C:\data\db

Step 4

  • cd to C:\Program Files\MongoDB\Server\3.2\bin>
  • enter command mongod
  • by default, mongodb server will start at port 27017

enter image description here

Step 5

  • (optionally) download RoboMongo and follow normal setup instructions

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Step 6

  • Start RoboMongo and create a new connection on localhost:27017

enter image description here

Your mongodb is started and connected with RoboMongo - a third party GUI tool

查看更多
干净又极端
4楼-- · 2019-01-12 16:02

This worked for me

mongod --port 27017 --dbpath C:\MongoDB\data\db
查看更多
做自己的国王
5楼-- · 2019-01-12 16:03

Create MongoDB Service in Windows. First Open cmd with administrator

mongod --port 27017 --dbpath "a mongodb storage actual path e.g: d:\mongo_storage\data" --logpath="a log path e.g: d:\mongo_storage\log\log.txt" --install --serviceName "MongoDB"

After that

Start Service

net start MongoDB

Stop Service

net stop MongoDB
查看更多
成全新的幸福
6楼-- · 2019-01-12 16:05

there are 2 ways start mongoDB Install location ( ex : C:/ )

first of all : copy mongoDB install folder into C:/ location then changed name to "mongodb" or something what u want. here is ex with "mongodb" name

1 : setup mongoDB is an windows service

    1.1 : Make directory name "data" in C:/ ( so we have C:/data ),after that make directory "C:/data/db" <br>
    1.2 : run in CMD ( Run as Admin) command ->  "echo logpath=C:/mongodb/log/mongo.log > C:/mongodb/mongodb.cfg" <br>
    1.3 : run in CMD (Run as Adin) command -> "C:/mongodb/bin/mongod.exe --config C:/mongodb/mongod.cfg --install" <br>
    1.4 : run command "net start MongoDB" <br>

2: a small .BAT file to start mongoDB without install copy and paste to notepad and save file with filetype ".bat" here is it :

C:\mongodb\bin\mongod.exe –dbpath=C:/mongodb/data/db
   PAUSE

if you getting error 1078 or 1087 lets remove all data in C:/data/db and restart mongoDB ( copy old data to new folder and back it up after restart mongoDB )

3 . GUI for mongoDB

i'm using rockmongo

have fun with it

查看更多
霸刀☆藐视天下
7楼-- · 2019-01-12 16:05

Installing MongoDB on Windows is a bit tricky compared to other Executable files... Got a good reference after long search I got Installing MongoDB in Windows

After Installing open command prompt and type "mongod", then keep the window minimized and open another command prompt window and type "mongo" and you will find the success message of connecting to the test database.

hope it helps

查看更多
登录 后发表回答