MongoDB 3.x installation and authorization verification

Source: Internet
Author: User
Tags mongodb setup

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.