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 linuxserver.io 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.

Anyway I believe I discovered how to do this however as usual I did it a few weeks ago I don’t exactly remember the process. It’s totally doable however but did take some research.

Would REALLY love detailed instructions.
It is really unusable to many of us.

It’s in the readme: GitHub - linuxserver/docker-unifi-network-application

Mongo also provides very thorough documentation for their container

Have to say I have already seen both and still didn’t manage.
The problem with those “guides” are that they expect a level of comfort with the tools already.

For example, the experience of someone using this through UNRAID is this:

  • Your previous UNA (that didn’t need any explisit mongodb setup) is said to be obsolete and you need to replace it with this one.
  • You go to the container library find it and notice that it needs various mongodb parameters set. You could just click next and ignore (and find out nothing works), or you see the docs and find the official mongodb container also through UNRAID interface, that in the container set up, doesn’t have any parameter to set anything related to the DB itself except the port (IIRC).
  • Mongodb container installs and runs. You enter in the console and hope for the best. Seeing the instructions, you try to make the .js file it asks, presumably in the root (container) folder to run it… you manage to make the file (and make it executable) using the few drops of linux knowledge (I used redirection from console to make the file with copy-paste and yes I edited the parameters that needed replacing) only to find that you cannot run .js just like that.

…so just to run UNA you now need to learn how to manage a separate container for a db used just for that container (at least in my case)…

The “detailed” documentation doesn’t look that detailed now.

It might be best for you to find a different container then? You’re not asking any questions that anyone can support you’re just complaining. You’re also trying to act as if you speak for all unraid users, but you do not, while unraid are mostly unable to read, that does not apply to all and the are PLENTY of unraid users using this just fine

My advice, read thoroughly and TRY, if you have issues after ask specific questions about the steps and the specific issues you are having (provide errors and logs)

If putting effort in isn’t your thing ubiquiti sells a device that runs this

Very well thank you.

If any UNRAID user has progressed further in this and can apparently read unlike me, please help me.

How can anyone help you? you provide no relevant detail useful for helping… provide your docker run, your full container logs, and describe the actual problem in some detail.

This is why I specify “UNRAID user”, because they most probably followed the same path. No need for docker run, as it wasn’t customized, it was what came up in apps.
What logs to provide about what error.

The issue is this: In the context of UNRAID being host, I cannot follow the steps needed to properly install mongodb with an actual database and user for it. So I never started UNA at all (no error, I didn’t install it before finishing mongodb steps). The path I follow above, makes sense to UNRAID users and may point me what I did wrong or what to do next.

You provided your feedback, “I cannot read” apparently. So, if someone coming from UNRAID can see what I did wrong, I am all ears (erm… eyes).

there is a need, else I wouldn’t have asked for it.

I would suggest that you move on to the unraid forums for help. You are complaining about something and now state you didn’t even try because unraid users can’t understand it? this is ridiculous and insulting to many users. I wish you luck in your endeavors, but I will be locking this thread.

1 Like