Skip to main content

Create MongoDB Database

As iterates, it may adopt new databases for storage. If database access authentication is enabled, you will need to create the required database in advance.

The following are instructions on how to create a database in two different modes of user's role and permission settings:

  • Separate user authentication for each database: it is necessary to create the same user as for the other databases using a user with the admin role, for example:

    mongo -u username -p password --authenticationDatabase admin
    use newdbname
    db.createUser({ user: "Change to the same username as in the other databases", pwd: "Change to the same password as in the other databases", roles: [{ role: "readWrite", db: "newdbname" }] })
  • The same user authentication for all databases: you need to modify the permissions of the user and authorize new databases.