This chapter covers how to administrate your collections and databases. Generally the things covered in this section are not daily tasks but can be critically important for your application’s performance, for instance:
Setting up authentication and user accounts
Creating indexes on a running system
“Preheating” a new server to allow it to come online quickly
Defragmenting data files
Preallocating new data files manually
One of the first priorities for systems administrators is to ensure their system is secure. The best way to handle security with MongoDB is to run it in a trusted environment, ensuring that only trusted machines are able to connect to the server. That said, MongoDB supports per-connection authentication, albeit with a fairly coarse-grained permissions scheme.
Each database in a MongoDB instance can have any number of users. When security is enabled, only authenticated users of a database are able to perform read or write operations.
There are two special databases: users in the admin and local databases can perform operations on any database. A user that belongs to either one of these databases can be thought of as a superuser. After authenticating, admin users are able to read or write from any database ...