MongoDB connection and turn on security verification

Source: Internet
Author: User
Tags auth robomongo

The first is to start MongoDB

A. Open CMD,CD to the bin directory under the installation directory of MongoDB, execute Mongod--dbpath D:\MongoDBdata (data storage directory)

Or add MongoDB to the environment variable, and then execute this command is also possible (in order to facilitate me to establish a. bat batch file, the command to start MongoDB write to the file, each time you want to start a direct double-click the file on it)

B. Execute commands directly after launch MONGO can enter MongoDB, or you can create a. bat batch file, write Mongo 127.0.0.1:27017/admin where admin is logged in, 27017 is the default listening port for MongoDB, and 28017 is the extension port for the Web service.

I. MongoDB enable security verification detection

MongoDB default is no user name and password, we installed the client of MongoDB, when local connection local client MONGO, directly on the MONGO on it, the default is 127.0.0.1, the default listening 27017 port, do not need any security authentication, So how do you turn on security verification?

If you want to turn on security verification, you must use--auth to turn on security checks.

To set the user name and password for MongoDB:

To create an administrator:

Use admin

Db. CreateUser ({User: "root", pwd: "123456", roles:["root"})//Add Administrator

Then restart MongoDB, but you must add the--auth option to modify the contents of the. bat file to: Mongod--auth--dbpath D:\MongoDBdata, and then double-click Start, at which point you do not have to do anything when you use the MONGO connection. Just like:

    

You are prompted, the unauthorized administrator executes the command, apparently the security verification check is turned on successfully, and you should be connected like this: MONGO admin-u root-p 123456

    

With the administrator account you just set up, our connection is successful, and the Security verification test opens

Or you can verify that (1 indicates success):

    

At this time when you use the MongoDB visualization tool to connect (I use Robomongo, can also use Mongovue, but basically no cracked version, and so on I will teach you how to use Vue when you can use it for free):

    

You will find that after the security verification detection is turned on, a key will appear, followed by the admin (Administrator's database)/root (Admin account)

  

Two. Visualization tool to connect MongoDB (Mongovue)

MongoDB before 3.2 By default is the MMAPV1 storage engine, 3.2 after the default is the Wiredtiger storage engine, how to identify their own mongodb open which engine? (see MongoDB Boot data storage directory)

Wiredtiger Engine:

  

MMAPV1 Storage engine (which I found on the Internet):

  

When our MongoDB is on the Wiredtiger storage engine, using Vue to connect mongodb its data is not displayed, that is, after you connect successfully, look at the Library of collections, show empty, why?

Because the file formats generated by the two storage engines are not compatible, the data files generated by the MMAPV1 storage engine are not readable by the Wiredtiger storage engine, how can I solve them? To tell the truth I have not found a solution, ashamed of very!!!!!!

The online solution is to specify MongoDB's storage engine directly when MongoDB starts, with the following command:

Mongod--storageengine wiredtiger--dbpath Data Catalog

Mongod--storageengine mmapv1--dbpath Data Catalog

But I and colleagues have experimented many times, the collection (collection) is not shown, so for the time being we use the visual tools are Robomongo

The following I teach you how to use Vue when you can register, can always use, in fact, is very simple, but a little trouble, this method is I see a teacher on the Internet tutorial, he taught, I am here to learn from:

Everyone in the official website download Good Mongovue, general use after 14 days will prompt you to register, or not use, at this time you can enter the computer registry, open cmd, enter regedit to enter the registration form

Then directly ctrl+f search "4ff78130", find the file inside, 14 days a Delete, 14 days a delete that's it.

    

  

MongoDB connection and turn on security 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.