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