Mongodb 简单配置和密码访问
Mongodb 简单配置和密码访问
1.配置
net: port: 27017 bindIp: 0.0.0.0 security: authorization: enabled systemLog: destination: file path: "/data/log/mongod.log" logAppend: true storage: dbPath: "/data/db" #processManagement: # fork: true
2.创建用户
use admin db.createUser({user: 'root', pwd: '123456', roles: ['root']}) use Article db.createUser({user:'test',pwd:'123456',roles: [{role:'readWrite',db:'Article'}]})})
3.pymongo连接
mongoClient = pymongo.MongoClient('mongodb://test:123456@localhost:27017/Article')db = mongoClient['article']results = db['article'].find({})for item in results: print(item)
How to make a backup of the mongodb database
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~