Jump to content

MongoDB: Difference between revisions

From NixOS Wiki
m fix typo in the link displayname
Notarin (talk | contribs)
m Ammended initialRootPassword -> initialRootPasswordFile
 
(2 intermediate revisions by 2 users not shown)
Line 7: Line 7:
...
...
</syntaxhighlight>
</syntaxhighlight>
{{warning|The default <code>mongodb</code> package does not provide pre-compiled binaries, and the package will be compiled locally. The alternate package <code>mongodb-ce</code> does however. You can configure the mongodb service to use this package with the following:<syntaxhighlight lang="nix">services.mongodb.package = pkgs.mongodb-ce;</syntaxhighlight>}}


== Configuration ==
== Configuration ==
Line 14: Line 15:
   package = "mongodb-5_0";
   package = "mongodb-5_0";
   enableAuth = true;
   enableAuth = true;
   initialRootPassword = "YourSecurePassword";
   initialRootPasswordFile = /path/to/secure/passwordFile;
   bind_ip = "10.5.0.2";
   bind_ip = "10.5.0.2";
};
};

Latest revision as of 03:31, 3 September 2025

MongoDB is a NoSQL database program.

Installation

If no extra configuration is needed, you'll only use the following line to install and enable MongoDB. This will give you a mongodb with authentication disabled, listening on 127.0.0.1 and the database path to store the data is /var/db/mongodb.

...
services.mongodb.enable = true;
...
⚠︎
Warning: The default mongodb package does not provide pre-compiled binaries, and the package will be compiled locally. The alternate package mongodb-ce does however. You can configure the mongodb service to use this package with the following:
services.mongodb.package = pkgs.mongodb-ce;

Configuration

Here's an example with multiple options. Beware that putting your password in cleartext into the config should not be done. Please check Comparison of secret managing schemes for that matter.

services.mongodb = {
  enable = true;
  package = "mongodb-5_0";
  enableAuth = true;
  initialRootPasswordFile = /path/to/secure/passwordFile;
  bind_ip = "10.5.0.2";
};