简体   繁体   English

mongodb设置数据库密码

[英]mongodb setting up a database password

I read through several docs on mongodb but I'm so confused that I'm posting this question. 我阅读了有关mongodb的一些文档,但是我很困惑,以至于我发布了这个问题。

Is there a way to set a password for a mongodb database? 有没有办法为mongodb数据库设置密码? That ways when I try to open the database via console or connect using mongoose/node.js I will need a password. 这样,当我尝试通过控制台打开数据库或使用mongoose / node.js连接时,我将需要密码。

Thank you. 谢谢。

There is the "auth" parameter to start mongod with required authentication. 有一个“ auth”参数可使用所需的身份验证启动mongod。 Therefor you have to create an admin user (a user which has admin privilegs like - creating other users and so on) and then you can create a user for read, readwrite or write rights for specific databases. 因此,您必须创建一个admin用户(一个具有admin特权(例如-创建其他用户等)的用户),然后才能创建一个对特定数据库具有读取,读写或写入权限的用户。 http://docs.mongodb.org/manual/reference/method/db.createUser/#create-administrative-user-with-roles http://docs.mongodb.org/manual/reference/method/db.createUser/#create-user-with-roles http://docs.mongodb.org/manual/reference/method/db.createUser/#create-administrative-user-with-roles http://docs.mongodb.org/manual/reference/method/db.createUser/ #create-user-with-roles

Important is, that you start your mongo db with the auth parameter after creating these users. 重要的是,创建这些用户后,请使用auth参数启动mongo db。

mongod --auth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM