MongoDB Password security settings

Source: Internet
Author: User
Tags auth install mongodb

  1. Download the MONGO installation package (recommended version after 3.0) version from the official website select the download link:

    https://www.mongodb.org/dl/win32/x86_64-2008plus-ssl?_ga=2.21045944.28077375.1495245189-20472680.1495115198

  2. To install MongoDB under D:\mongodb
  3. Create a storage location for the database files, such as D:/mongodb/data (you must create a storage folder for the database before you start the MongoDB service, otherwise it will not be created automatically and cannot be started successfully)
  4. Create a new folder log (log file) under D:\mongodb\log and create a new file Mongodb.log
  5. d:\mongodb new file Mongo.config profile dbpath=d:\mongodb\data
    Logpath=d:\mongodb\log\mongo.log
  6. Configuring the MongoDB installation path in environment variables
  7. Open the command line line to start Mongod:mongod--config D:\mongodb\mongo.config (mongod--config D:\mongodb\mongo.config--install--servicename "MongoDB" boot )
  8. Reopen a command-line input: MONGO
  9. Create superuser (need to enter admin database First, not create):-Use admin
    -Db.createuser (
    -   {
    -User: "admin",
    -pwd: "admin",
    -Roles: [{role: ' Useradminanydatabase ', db: ' admin '}]
    -   }
    - )# Create low-privileged users
    -Db.createuser (
    -   {
    -User: "MyUser",
    -pwd: "MyUser",
    -Roles: [{role: ' ReadWrite ', db: ' MyDB '}]
    -   }
    - )
  10. added in configuration file mongo.config: Auth=trueDbpath=d:\mongodb\data
    Logpath=d:\mongodb\log\mongo.log
    auth=true

11. Restart Mongod: mongod--config D:\mongodb\mongo.config

12. Open another command window to connect the MONGO:

MONGO
Show DBS (show no access)
# because it is created in the admin database, it can only be logged in the Admin database and cannot be authenticated in other databases .
# After authentication, you can switch to other databases for related operations.
Use admin
Db.auth ("xxxx", "xxxx")
now it's ready to operate.

    • Troubleshoot Robomong connectivity Issues

When using the Robomong connection requires a password-verified MongoDB, the display does not connect properly, now use the following methods to resolve

 1. Delete the previously created User: Db.dropuser ("admin");2. Then delete the Mongdb.config:auth=true3. Restart Mongod, then connect again4, UEs Admin modified version:db.system.version.update ({"_id": "Authschema"},{$set: {"CurrentVersion": 3}})5. Re-create the user:Db.createuser ({User: "root", pwd: "123456", roles:[{"role": "Root", "db": "Admin"}]})6, restart the MONGDB service, open the Robomong, set the account number and password (is set in the MONGO account and password) again test, you can link the normal If Mongod is started after boot, you need to close the service in the background and then use the following command to turn on MongoDB security authenticationFirst command line open:mongod--config D:\mongodb\mongo.config re-command line connection: MONGO

MongoDB Password security settings

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.