mongoexport -h 192.168.6.66 --port 27017 -u dbAdmin -p L-$LpGQ=FJvSf*****([l --authenticationDatabase=project_core_db -d project_core_db -c TradeRecordDetail -o D:/TradeRecordDetail.json

mongoimport -h 127.0.0.1 --port 27017 -u root -p 123456 --authenticationDatabase=admin -d test -c TradeRecordDetail --upsert --drop D:/TradeRecordDetail.json

 

mongodump -h 127.0.0.1:27017 -u root -p 123456 --authenticationDatabase=admin -d test -o D:/mongo/dump

mongorestore -h 127.0.0.1:27017 -u root -p 123456  --authenticationDatabase=admin  -d project_core_db D:\mongo\dump\project_core_db

 

> use admin
switched to db admin
> db.auth('root','123456')
> use project_core_db
switched to db project_core_db
> db.createUser({user:'hanli',pwd:'hanli',roles:[{role:'dbAdmin',db:'project_core_db'}]})
Successfully added user: {
        "user" : "hanli",
        "roles" : [
                {
                        "role" : "dbAdmin",
                        "db" : "project_core_db"
                }
        ]
}
>

 

use admin
创建超级管理员
db.createUser(  
  {  
    user:"root",  
    pwd:"82xo#F*N6LC(vWwC",  
    roles:["root"]  
  }  
)
db.auth('root','82xo*N6LC(vWwC')
use project_core_db
创建正式库读写用户
db.createUser(  
  {  
    user:"customer",  
    pwd:"q=%bJ~*!PhfHG",  
    roles:[{role:"readWrite",db:"project_core_db"}]  
  }  
)  
创建正式库运维用户
db.createUser(  
  {  
    user:"dbAdmin",  
    pwd:"L-$LpGQ=F**RsFHI.$([l",  
    roles:[{role:"dbAdmin",db:"project_core_db"},{role:"readWrite",db:"project_core_db"}]  
  }  
)  

 

posted on 2018-03-26 16:13  chester·chen  阅读(2180)  评论(0编辑  收藏  举报