Installing and setting up MongoDB on Windows
- Run with root access:
Run as the system administrator. - Download MongoDB:
https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-3.2.1.zip http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.8.zip(Or, to get specific versions: http://www.mongodb.org/downloads#previous ) - Extract (unzip) the MongoDB archive:
- Copy MongoDB to the target directory:
- Create c:\dbdata\mongodb
- Move the extracted folder to c:\dbdata\mongodb
- Create the database data directory:
Create c:\dbdata\mongodatawt Create a key file that your deployment will use to authenticate servers to each other.
Ensure that your key file meets the following requirements:- Contains 6 to 1024 characters and contains only characters in the base64 set.
- Setting keyFile enables authentication and specifies a key file for the replica set members to use when authenticating to each other.
- Key file content is arbitrary but is the same on all members of the replica set instances that connect to the set.
Create the mongo.key file in c:\dbdata\mongodb with the following content: mysecretkey007
Set the storage engine to wiredTiger for better performance and reduced storage.
Run the following command:c:\dbdata\mongodb\mongodb-win32-x86_64-2008plus-3.2.1\bin\mongod.exe --dbpath c:\dbdata\mongodatawt --port 27017 --storageEngine wiredTigerConnect to the mongo shell and create the administrator user and the social database administrator:
use admin
db.createUser( {
user: "siteUserAdmin",
pwd: "password",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
});
db.createUser( {
user: "siteRootAdmin",
pwd: "<siteRootAdminPassword>",
roles: [ { role: "root", db: "admin" } ]
});
use social
db.createUser( {
user: "social_admin",
pwd: "<social_adminPassword>",
roles:
[ { role: "dbOwner", db: "social" } ]
});- Stop the mongo process that was started.
- Start the MongoDB service with the key file:
Create the file c:\dbdata\mongodb\mongodb-win32-x86_64-2008plus-3.0.8\mongod.cfg and add following settings:
dbpath=c:\dbdata\mongodatawt
port=27017
logpath=c:\dbdata\mongodb\mongo_social.log
logappend=true
quiet=true
journal=true
replSet=myitsocial
keyFile = c:\dbdata\mongodb\mongo.key
nohttpinterface = true
storageEngine = wiredTigerAs administrator, open the command prompt window and run the following command:
c:\dbdata\mongodb\mongodb-win32-x86_64-2008plus-3.2.1\bin\mongod.exe --config c:\dbdata\mongodb\mongodb-win32-x86_64-2008plus-3.2.1\mongod.cfg --install- To start the service, run the net start MongoDB command.
- (For high-availability) After installing and setting up MongoDB on WIndows, go to Configuring-MongoDB-for-replica-set.
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*