First go to the official website http://www.mongodb.org/Download MongoDB
Extract D:\mongodb after download create two new folders data and log
Create a new file named Mongodb.cfg
Dbpath=d:\mongodb\data
Logpath=d:\mongodb\log\mongo.log
How to set up as a Windows service
Mongod--bind_ip youripadress--logpath "C:\data\dbConf\mongodb.log"--logappend--dbpath "C:\data\db"--port Yourportnumber--servicename "Yourservicename"--servicedisplayname "Yourservicename"--install
The cmd command enters the D:\mongodb\bin input MONGO to connect to the database.
How to manipulate MongoDB through Java
First go to https://github.com/mongodb/mongo-java-driver/downloads to download the corresponding jar package based on your MongoDB version.
And the following is a connected Java program
Package Mongo;import Com.mongodb.db;import Com.mongodb.mongo;public class Connection {public static void main (string[] args) throws Exception{mongo m = new Mongo ("localhost", 27017);D b DB = M.getdb ("Company"); if (Db.authenticate ("Test", "123 ". ToCharArray ())) {System.out.println (" Success ");} ELSE{SYSTEM.OUT.PRINTLN ("fail");}}}
MongoDB Initial Contact