This is my first post as using the mongodb. First, I just downloaded the installer file from mongodb site. There are some points to remember if you install mongodb for the first time.
create c:\mongodb folder
- this is to be used for the custom installation
create \data\db folder
- put under the mongodb folder, use for database data file
create \logs
- for the mongodb log file
open powershell by run by administrator access and execute below command
>.\mongod.exe --directoryperdb --dbpath c:\mongodb\data\db --logpath c:\mongodb\logs\mongo.log --logappend --rest --install
start the mongodb service
>net start MongoDB
> show dbs
admin 0.000GB
local 0.000GB
> use mycustomers
switched to db mycustomers
> db
mycustomers
> show dbs
admin 0.000GB
local 0.000GB
> db
mycustomers
> db.createUser({
... user:"brad",
... pwd:"1234",
... roles: ["readWrite", "dbAdmin"]
... });
Successfully added user: { "user" : "brad", "roles" : [ "readWrite", "dbAdmin" ] }
> db.createCollection('customers');
{ "ok" : 1 }
> show collections
customers
> db.customers.insert({first_name:"John", last_game:"Doe"});
WriteResult({ "nInserted" : 1 })
> db.customers.find();
{ "_id" : ObjectId("5965cba0a07b84a6ed70301a"), "first_name" : "John", "last_game" : "Doe" }