1. First download the MongoDB installation package on the Internet, I use the 3.2 version on this side;
2. Install the MongoDB Setup program, set the environment variables after installation, the installation path of my side is: "C:\Program files\mongodb\server\3.2\bin", after installation I created 2 folders in the directory: "Data" and "log ”,
Environment variables:
Installation directory:
In the log directory also need to create a text file, the modified file name is: "Mongodb.log", this is the log file:
3. Open a command prompt as an administrator, enter: Mongod--dbpath "C:\Program files\mongodb\server\3.2\bin\data", carriage return;
4. Above the life of the window do not close, at this time, as an administrator to open a command Prompt window , enter: MONGO 127.0.0.1, this will be displayed:
5. Add users under Database-oriented:
Various user role permissions (copy from other blogs):
1. Database user role: Read, readWrite;
2. Database Management role: DbAdmin, Dbowner, useradmin;
3. Cluster Management role: Clusteradmin, Clustermanager, Clustermonitor, Hostmanager;
4. Backup Restore role: backups, restore;
5. All database roles: Readanydatabase, Readwriteanydatabase, Useradminanydatabase, dbadminanydatabase
6. Super User role: Root
7. Internal role: __system
6. Close the two Command prompt window and Create a text file that modifies the name: Install.bat;
Text file content modified to:
@echo
Mongod--bind_ip 127.0.0.1--logpath "C:\Program files\mongodb\server\3.2\bin\log\mongodb.log"--logappend--dbpath "C : \program Files\mongodb\server\3.2\bin\data "--port 27017--servicename" MongoDB Service "--servicedisplayname" MongoDB Service "--auth--install
net start "MongoDB Service"
Pause
Close, save, and open this batch file as an administrator, you can add MONGO to the system service and start.
Deft on hand the batch file to execute the display of the command window is closed, so no ...
7. I open the Command Prompt window again (not necessarily the administrator), enter the command:
MONGO 127.0.0.1
Show successful Connection
Then enter: Show DBS
Display not authorized
Input: Use admin
Input: Db.auth ("root", "root")
Show authorization success, enter again: Show DBS
Displays the collection of databases in the current database
Operation Process
OK, End!
MongoDB 3.x installation and authorization verification