How to set up MongoDB for Sitecore

Step 1: Download and Install MongoDB in the following path (c:\mongodb)
Step 2: Create folders and configuration file
Step 2.1: Create a folder (c:\mongodb\data)
Step 2.2: Create a folder (c:\mongodb\data\db)
Step 2.3: Create a folder (c:\mongodb\data\log)
Step 2.4: Create a file mongod.cfg inside (c:\mongodb\config) that also needs to be created
Step 2.5: Insert the following into the file that you created (mongod.cfg):

destination: file
path: c:\mongodb\data\log\mongod.log
dbPath: c:\mongodb\data\db

Step 3: Install the MongoDB service

sc.exe create MongoDB binPath= "C:\mongodb\bin\mongod.exe --service --config=\"C:\mongodb\config\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

Step 4: Start the MongoDB service

net start MongoDB

Step 5: Create the Databases

Step 5.1:

use admin

Step 5.2:

db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "userAdminAnyDatabase", db:"admin" }, { role: "root", db:"admin" } ] })

Step 5.2:


Step 5.3:

use analytics
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"analytics" } ] })
use tracking_live
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"tracking_live" } ] })
use tracking_history
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"tracking_history" } ] })
use tracking_contact
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"tracking_contact" } ] })

Step 6: Add the following to the ConnectionStrings.config

<add name="analytics" connectionString="mongodb://USERNAME:PASSWORD@localhost/analytics"/>
<add name="" connectionString="mongodb://USERNAME:PASSWORD@localhost/tracking_live"/>
<add name="tracking.history" connectionString="mongodb://USERNAME:PASSWORD@localhost/tracking_history"/>
<add name="" connectionString="mongodb://USERNAME:PASSWORD@localhost/tracking_contact"/>

To view the databases that you created. I recommend to download RoboMongo. Install it and create a basic connection name is “Sitecore” and see them all.