MongoDB permission connection Server

Source: Internet
Author: User

First, when you start Mongo, you need to add a very heavy parameter. -- Auth with this parameter will enable severe permissions. Therefore, the owner is not responsible for permission verification by default.

 
#./Mongod -- dbpath/data/mongo_data/-- logpath/data/mongo_log/mongolog. log -- auth -- logappend &

-- Dbpath
Yesdata address, which can be customized
-- Logpath
Is the log file address, which can be customized
-- AuthPermission Verification-- LogappendAccumulate logs
After the startup is complete, you can now use the permission Link

 
#./Mongo database name-u username-P Password
Use Program You must add

 
DB. Authenticate (username, password. tochararray ());
 
String address = cfgmap. get ("Mongo. DB. address "); int Port = integer. parseint (partition map. get ("Mongo. DB. port "). tostring (); string dbname = cfgmap. get ("Mongo. DB. dbname "); string username = cfgmap. get ("Mongo. DB. username "); string Password = shortmap. get ("Mongo. DB. password "); Mongo = new Mongo (address, Port); If (dbname! = NULL &&! "". Equals (dbname) {DB = Mongo. getdb (dbname); If (username! = NULL &&! "". Equals (username) {// Authenticate identity dB. Authenticate (username, password. tochararray () ;}mongodbs. Put (dbname, DB );}



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.