var conn = new Mongo('host:port');
db = conn.getDB('admin');
db.auth('root', 'test');
database_names = ["crawl_data","company_data","crawl_merge_linkattr","crawl_merge_webpage","crawl_params","final_data","mfile","schedule_data","task_collect", 'single_src']
for(var i = 0; i < database_names.length; i++){
var database_name = database_names[i]
db = conn.getDB(database_name);
var result = db.getUser('work')
if (result != null)
{
continue
}
db.createUser(
{
user:"work",
pwd:"haizhi",
roles:[
{role:"readWrite",db:database_name}
]
}
)
}
/home/work/env/mongodb/bin/mongo Crawler-DataServer1:40042 create_mongodb.js
阅读(643) | 评论(0) | 转发(0) |