MongoDB installation To create user, authentication Auth,httpinterface

Source: Internet
Author: User
Tags auth create mongodb

Today took a day to solve this mongodb puzzle, if you have encountered other problems, you can consult me.

#开始 2.6.10 How to set user permissions differently after different versions of the installation

#下载这个版本的mongodb
Mongodb-linux-x86_64-2.6.10.gz
#解压到当前目录
TAR-ZXF mongodb-linux-x86_64-2.6.10.gz
#更改文件夹名称
MV mongodb-linux-x86_64-2.6.10 mongodb2.6.10

#在mongodb2.6.10 The folder you need to create MongoDB
#数据存放路径
data/db
#配置路径
Conf
#日志路径
Log

#27017. conf is configured as follows (the configuration file is placed under the Conf directory):
Quiet = True
Port = 27017
LogPath =/home/wang/mongodb2.6.10/log/27017.log
Logappend = True
DBPath =/home/wang/mongodb2.6.10/data/db
Directoryperdb = True
Journal = True
Fork = True

#根据参数配置启动mongodb, start with the authentication user.
./mongod-f/home/wang/mongodb2.6.10/conf/27017.conf--auth

#进入dos界面设置用户
./mongo
#使用logdb数据库, no system is created automatically
Use Logdb

#创建用户, read and Write permissions (if additional permissions are required, search online)
Db.createuser ({"User": "Logger",
"pwd": "123456",
"Roles": [{role: "ReadWrite", DB: "Logdb"}
]
})
#授权
Db.auth (' logger ', ' 123456 ');

#用户管理员和数据库管理员 Permissions (Reference)
Db.createuser ({"User": "admin",
"pwd": "admin",
"Roles": [{role: ' Useradminanydatabase ', db: ' admin '},
{role: "Dbadminanydatabase", DB: "Admin"}
]
})
#授权
Db.auth (' admin ', ' admin ');


################ #MongoDB Web Management ####################
Launch reference:./mongod-f/home/wang/mongodb2.6.10/conf/27017.conf--httpinterface--rest
#mongodb最高级用户root Remove the--auth before executing this permission. Need to execute under Use admin, Reboot MongoDB plus--auth after successful execution.
#就可以使用root管理web界面了, you can see a lot of system performance consumption status from the management interface.

Db.createuser ({
User: ' Root ',
PWD: ' Root ',
Roles: [{
"Role": "Root",
"DB": "admin"
}]
});
./mongod-f/home/wang/mongodb2.6.10/conf/27017.conf--httpinterface--auth--rest
#访问端口比原端口号大1000 Access Address: http://192.168.1.89:28017/

################ #结束 #################

MongoDB installation To create user, authentication Auth,httpinterface

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.