Sunday, 25 December 2016

Install Mongo Db Like a Pro



Mongo Db installation Guide:

1. Go to the URL : https://www.mongodb.com/download-center/community/releases/archive

2. Select software a sepecific version & for specific OS e.g: Windows selected below:



3. Select a binary in .zip format , from the link:

4. Download it into a repository, and extract it into an installation directory.

5. Create data directories for installation:

1. D:/Mongo/Data - for data files
2. D:/Mongo/Log - for log files
3. D:/Mongo/Config - for configuration files


6. Create a configuration file [mongod.conf] into Config[D:/Mongo/Config] and paste the below content into the file and save it:

storage:
   dbPath: "C:/Mongo/Data"

systemLog:
   destination: file
   path: "C:/Mongo/Log/mongod.log"


Note: it must be in YAML format that is 3 space from left end.

7. We need to give user(a service account) full access to this installation directory, form the same we will use this command:

Icacls d:\mongo /grant Avinash:(OI)(CI)F


8. Now, install mongo db as service on windows server , using command:

 mongod --install --config d:\mongo\config\mongod.conf --serviceUser Avinash --servicePassword ************

9. Now, we will verify whether it is installed or not.

sc qc mongodb

10. We will start the mongodb service now, by running the command:

net start mongodb

11. Create a db by following this command:

use test_dev_db

12. Provide permission to the a specific user using the following commmand:

db.createUser(
  {
    user: "avinashthakur",
    pwd: "Bangalore#12345",
    roles: [
       { role: "readWrite", db: "test_dev_db" },
       { role: "readWrite", db: "test" },
       { role: "readWrite", db: "admin" }       
    ]
  }
)

13. It is ready to use. You may follow my other article for CRUD operation in Mongodb 

1 comment: