启用访问控制

时间:2017-08-17 22:16:07

标签: mongodb shell access-control

我最近安装了mongo db并且第一次运行它。我遇到了这个警告,

@ViewChild('fileInput2') private thumbImageInput: ElementRef;
// and in the addThumbnail method: 
addThumbnail(event) {
    var subscription = this.readImage2(event.target).subscribe((result) => {
        this.thumbnails.push(result.imageUrl);
        this.editedThumbnails.push(result.imageUrl);
        window.URL.revokeObjectURL(result.imageUrl);
        this.thumbImageInput.nativeElement.value = '';
    });
}

我通过使用这些命令启用访问控制来解决此问题

 Access control is not enabled for the database.
 Read and write access to data and configuration is unrestricted.

从文档中,我必须使用以下命令重新启动mongodb:

 db.createUser( 
  { 
    user:"myuserName", 
    pwd:"myPassword", 
    roles:[{role: "userAdminAnyDatabase", db:"admin"}]
  })

但是当我尝试在访问控制后重启mongodb时,我收到了这个错误。

mongod --auth --port 27017 --dbpath /data/db

命令错了还是我错过了什么。请告诉我这个。感谢。

0 个答案:

没有答案
相关问题