MongoDB what are the default user and password?

前端 未结 4 1245
傲寒
傲寒 2020-12-22 17:14

I am using the same connection string on local and production. When the connection string is mongodb://localhost/mydb

What is the username and password?

4条回答
  •  执念已碎
    2020-12-22 18:06

    In addition with what @Camilo Silva already mentioned, if you want to give free access to create databases, read, write databases, etc, but you don't want to create a root role, you can change the 3rd step with the following:

    use admin
    db.createUser(
      {
        user: "myUserAdmin",
        pwd: "abc123",
        roles: [ { role: "userAdminAnyDatabase", db: "admin" }, 
                 { role: "dbAdminAnyDatabase", db: "admin" }, 
                 { role: "readWriteAnyDatabase", db: "admin" } ]
      }
    )
    

提交回复
热议问题