Installation and MongoDB service configuration for MongoDB
Mongo DB is a kind of non relational database (NOSQL) which is very popular in the IT industry, and its flexible data storage is favored by the current IT practitioners. Mongo db is a good way to implement object-oriented thinking (OO), where each record in Mongo DB is a document object. The biggest advantage of Mongo DB is that all data persistence operations require no developer to manually write SQL statements, and the direct invocation of the method makes it easy to implement CRUD operations.
First, Installation:
1. Official website: http://www.mongodb.org/downloads, download the corresponding system of the 32/64-bit MSI format installation package
2. Installation path: Example D:\MongoDB (path optional, but not too deep)
3. Configuration after installation:
Create a new Data folder under D:\MongoDB\
Create a new DB and log folder under D:\MongoDB\data
Create a new MongoDB.log file under D:\MongoDB\data\log
Second, start:
1. Entering D:\MongoDB\bin, enter:
1 Mongod–dbpath D:\MongoDB\data\db
Role: Create a MongoDB database file to the D:\MONGODB\DATA\DB directory
At this point the interface will stop
2016-10-26t14:55:37.044+0800 I Network [Initandlisten] waiting for connections on port 27017
The database is now started.
2. Open a new CMD window, run Mongo.exe program, this time before a window display
2016-10-26t14:56:05.855+0800 I Network [Initandlisten] connection accepted from 127.0.0.1:60584 #1 (1 connection now OPEN)
You can now use the MongoDB database.
Third, the use of:
1. In the cmd window where you previously ran Mongo.exe, enter the use TestDB to create the TestDB database.
2. Enter Db.adduser ("Test", "123") to create a user for TestDB
Note: The V3 version MongoDB is no longer using adduser, but it uses the Db.createuser
1
2
3
4
5
6
7 Db.createuser (
{
User: "Accountuser",
PWD: "Password",
roles: ["ReadWrite", "Dbadmin"]
}
)