Create root user and password in mongodb when using Unifi Network Application

So I had opportunity to setup the Unifi Network Application this weekend. Really impressed with the team and the bunch of users which have provided examples. I used the init script method to setup the databases for unifi.

The documentation states when using the init script method:

If you are using the init script method do not also set MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD, or any other “INITDB” values as they will cause conflicts.

So, my question is after the database is created, how do you go about creating a ROOT username and ROOT PASSWORD after the container has be created? I don’t know a lot about mongodb and I’ve mostly worked with postgresql in the past, however from everytime I’ve setup a db in the past, I think I set it up initially with root user and passsword — not after the fact. Does anyone have any insight how to accomplish this?

I have exactly the same question!

Moreover, were you able to run the Unifi Network Application? I simply can’t. I launch the mongodb container and then the unifi network application container but the latter can’t connect to the DB for some reasons. I get an error that reads - Got error while connecting to db: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-256, ....

I’m getting crazy!

These kind of questions are best answered by reading mongodb’s documentation. mongodb is not mysql, mariadb, postgresql, or mssql.