β

Mongodb 简单配置和密码访问

Waiting For You 137 阅读

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']})
db.auth('root','123456')
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)

http://www.waitingfy.com/archives/3363

作者:Waiting For You
记录一些关于android,cocos2d-x,objective-c,mfc,directX,c++,数学的东西
原文地址:Mongodb 简单配置和密码访问, 感谢原作者分享。

发表评论