- add auth=true in mongo.cfg file
- Start mongod.exe in console or use windows service configured in (http://devsuggestion.blogspot.com/2014/10/mongodb-windows8-installation.html)
- Start mongo.exe in another console
- use admin
- db.addUser("user","password")
- use test
- db.auth("user","password")
- db.addUser("testuser","testpassword")
- Now test db is accessible using username/password only
Friday, October 10, 2014
Windows 8 MongoDB in secure mode
Thursday, October 9, 2014
Java code to generate BigDecimal Random value
To generrate BigDecimal between 0 to defined range use following code:
private BigDecimal randomNo(int range) {
BigDecimal rangeInBD = new BigDecimal(range);
BigDecimal randomNoGeneration = new BigDecimal(Math.random()); // between 0 to < 1.0
BigDecimal actualRandonNo = randomNoGeneration.multiply(rangeInBD);
return actualRandonNo.setScale(2, BigDecimal.ROUND_HALF_UP);
}
Wednesday, October 8, 2014
MongoDB windows 8 installation
- Download from https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.4-signed.msi?_ga=1.92201882.1006826747.1412750869
- Install downloaded msi
- Move installed directory from default location C:\Program Files\MongoDB 2.6 Standard to your user defined location, something without space in naming convention, this is a good practice. Copying the installed folder to another location will not create any issue as MongoDB is self-contained and does not have any other system dependencies. For example: C:\poc\mdb\MongoDB_2.6_Standard
- Create a mongo.cfg file with content:
##store data here (make sure you have manually created following directory)
dbpath=C:\poc\mdb\data
##all output go here (make sure you have manually created following directory)
logpath=C:\poc\mdb\log\mongo.log
- Open command prompt (WIN +X ) and open Comman Prompt (Admin)
- Type following:
sc.exe create MongoDB binPath= "\"C:\poc\mdb\MongoDB_2.6_Standard\bin\mongod.exe\" --service --config=\"C:\poc\mdb\mongod.cfg\"" DisplayName= "MongoDB_2.6_Standard" start= "auto"
- MongoDB service is successfully installed if you see following msg:
[SC] CreateService SUCCESS
- Start MongoDB service:
net start MongoDB
- To stop MongoDB service:
net stop MongoDB
- To delete MongoDB service
sc.exe delete MongoDB
Source: http://www.mongodb.org
Subscribe to:
Posts (Atom)