Use MongoDB

I am to do a practice on one of the popular no-sql database: MongDB. Never used no-sql db before, but will verify its functions.

  1. Download MongDB (Current community version 3.6)
  2. Create c:\data\db, this is default data folder, there is not necessary to change to somewhere else
  3. Add installation bin path into system path, for example: c:\mongodb\bin
  4. Start Mongdb. Open cmd window, in bin path: Mongod.exe. The problem will listening port 27017
  5. Open another cmd window and run: mongo.exe. the first cmd window will list listen information.
  6. Create a log file folder: C:\Data\log, create an empty mongod.log file in this folder

So far the MongDB has been successfully installed in the server, the next step is to make it remote access.

  1. Open 27017 inbound role from windows firewall
  2. The remote access needs we enable user auth first, otherwise mongo db can be access from everyone. 
    • in another cmd, run mongo
    • run command: use admin; this will select admin database
    • run the following command to create admin user: 
        user : "admin",
        pwd  : "password",
        roles: [
            role: 'root', db: 'admin'
    • run the following code to assign the user role:
          [{ "role" : "readWriteAnyDatabase", "db" : "admin" },{ role: "userAdminAnyDatabase", db: "admin" }]
  3. create mongod configuration file mongod.conf, this file will includes some options when starting Mongo DB:

    1. In cmd window, run: mongod --config mongod.conf. The mongodb can be connected from remote machine now. 
    2. Mongo DB Compass is a very good UI tool. Download this tool and install this tool to the client side. By using this tool we can manage the remote mongo DB. But the tools is so simple it can only manage the database/collection objects:

    However, there is another GUI tool: NoSQL Manager for MongoDB, looks like much better than MongoDB Compass"

Sounds pretty straightforward.  


Add comment