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 16:09

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"
查看更多
Juvenile、少年°
3楼-- · 2019-01-12 16:09

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.

查看更多
SAY GOODBYE
4楼-- · 2019-01-12 16:15

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)
查看更多
女痞
5楼-- · 2019-01-12 16:16

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

查看更多
一纸荒年 Trace。
6楼-- · 2019-01-12 16:18
  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 !!!

查看更多
女痞
7楼-- · 2019-01-12 16:18

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....

查看更多
登录 后发表回答