How do I start Mongo DB from Windows?

99

44

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.

user3095838

Posted 2013-12-27T07:31:13.417

Reputation: 630

1

possible duplicate of Cannot start local mongo db

– karthick – 2013-12-27T07:41:49.550

For mongo client just check this one http://robomongo.org/

– karthick – 2013-12-27T07:43:24.667

Windows installation need to be completed and then configured before starting. watch this for steps - Mongo 3 - https://www.youtube.com/watch?v=msQ2F5XUgms

– Linus – 2017-04-23T02:43:29.563

Answers

224

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

student

Posted 2013-12-27T07:31:13.417

Reputation: 10 122

75

This worked for me

mongod --port 27017 --dbpath C:\MongoDB\data\db

Ar maj

Posted 2013-12-27T07:31:13.417

Reputation: 1 104

5Be sure that the path to the mongod.exe binary has to the $path variable or that you are in the directory with the mongod executable. – Shrout1 – 2016-10-05T14:49:09.093

but I need to do this every time is there any other way to do this by simple mongod command – Revansiddh – 2018-06-21T06:36:04.903

48

  1. Download from http://www.mongodb.org/downloads
  2. Install .msi file in folder C:\mongodb
  3. Create data, data\db, log directories and mongo.config file under C:\mongodb.
  4. Add the following lines in "mongo.config" file

    port=27017
    dbpath=C:\mongodb\data\db\
    logpath=C:\mongodb\log\mongo.log
    
  5. Start server :

    mongod.exe --config="C:\mongodb\mongo.config"
    
  6. Connect to localhost MongoDB server via command line

    mongo --port 27017
    
  7. Connect to remote MongoDB server via command line with authentication.

    mongo --username abcd --password abc123 --host server_ip_or_dns --port 27017
    

That's it !!!

Satishakumar Awati

Posted 2013-12-27T07:31:13.417

Reputation: 2 030

24

Step 1: First download the .msi i.e is the installation file from

https://www.mongodb.org/downloads#production

Step 2: Perform the installation using the so downloaded .msi file.Automatically it gets stored in program files. You could perform a custom installation and change the directory.

After this you should be able to see a Mongodb folder

Step 3: Create a new folder in this Mongodb folder with name 'data'. Create another new folder in your data directory with the name 'db'.

Step 4: Open cmd. Go to the directory where your mongodb folder exists and go to a path like C:\MongoDB\Server\3.0\bin. In the bin folder you should have mongodb.exe

Step 5: Now use

mongod --port 27017 --dbpath "C:\MongoDB\data\db"

Vinay Jaju

Posted 2013-12-27T07:31:13.417

Reputation: 437

14

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

CoderSpeed

Posted 2013-12-27T07:31:13.417

Reputation: 141

the correct option is: "--dbpath=C:/mongodb/data/db" (double dash) – Roberto – 2017-02-11T09:12:45.400

13

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

Soham Krishna Paul

Posted 2013-12-27T07:31:13.417

Reputation: 254

10

I have followed the below steps...May be it will work for you

Create directory like below

C:\DATA\DB

mongod --port 27017 --dbpath "C:\data\db"

It worked for me....

TechDog

Posted 2013-12-27T07:31:13.417

Reputation: 1 790

5

It is properly written over here

If you download the .msi file then install it and if you download the zip file then extract it.

Set up the MongoDB environment.

MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db. Create this folder using the following commands from a Command Prompt:

md \data\db

You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:

C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data

If your path includes spaces, enclose the entire path in double quotes, for example:

C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"

You may also specify the dbpath in a configuration file.

Start MongoDB.

To start MongoDB, run mongod.exe. For example, from the Command Prompt:

C:\mongodb\bin\mongod.exe

Connect to MongoDB.

To connect to MongoDB through the mongo.exe shell, open another Command Prompt.

C:\mongodb\bin\mongo.exe

vipin

Posted 2013-12-27T07:31:13.417

Reputation: 137

4

It is showing admin web console waiting for connections on port 28017.

The above message means that mongodb has started successfully and is listening on port 28017.

You can use the mongo shell(mongo.exe) to connect to the mongoDB and perform db operations.

There are several GUI tools available for MongoDB like MongoVUE, etc.

4J41

Posted 2013-12-27T07:31:13.417

Reputation: 3 946

2

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

Zub

Posted 2013-12-27T07:31:13.417

Reputation: 541

2

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.

oklas

Posted 2013-12-27T07:31:13.417

Reputation: 3 254

2

This is ALL I needed to init mongo in PowerShell, many replies are IMO too sophisticated.

  1. Install: https://www.mongodb.com/download-center#community
  2. Add C:\Program Files\MongoDB\Server\3.6\bin to environmental variable "path". Notice: this version will be outdated soon.
  3. Turn on new PowerShell, as it gets environmental variables on a start, then type mongod
  4. Open another PowerShell window and type mongo - you have access to mongo REPL! If you don't, just repeat 4 again (known bug: https://jira.mongodb.org/browse/SERVER-32473)

Przemo

Posted 2013-12-27T07:31:13.417

Reputation: 145

0

Clearly many people have answered upon your query of how to make mongoDb work, I'd answer the second part: Regarding an appropriate GUI for mongoDB

My suggestion is, go for MongoChef (now Studio 3T)

You can easily install and use it.

You might want want to refer to (from 03:10- to 08:50): https://www.youtube.com/watch?v=0ws3oIyqieY&index=2&list=PLS1QulWo1RIZtR6bncmSaH8fB81oRl6MP

For a step by step guide to the GUI tool.

Manthan_Admane

Posted 2013-12-27T07:31:13.417

Reputation: 51