MongoDB Documentation, Release 3.0.4 Considerations Procedure Next Steps This document outlines a procedure for enabling authentication for MongoDB instance where you create the first user on an existing MongoDB system that does not require authentication before restarting the instance and requiring au- thentication. You can use the localhost exception (page 324) to gain access to a system with no users and authentication enabled. See Enable Client Access Control (page 357) for the description of that procedure. Step 1: Start the MongoDB instance without authentication. Start the mongod or mongos instance without the authorization or keyFile setting. For example: mongod --port 27017 --dbpath /data/db1 For details on starting a mongod or mongos , see Manage mongod Processes (page 224) or Deploy a Sharded Cluster (page 691). Step 2: Create the system user administrator. Add the user with the userAdminAnyDatabase (page 412) role, and only that role. The following example creates the user siteUserAdmin user on the admin database: Step 3: Re-start the MongoDB instance with authentication enabled. Re-start the mongod or mongos instance with the authorization or keyFile setting. Use authorization on a standalone instance. Use keyFile on an instance in a replica set or sharded cluster . The following example enables authentication on a standalone mongod using the authorization command-line option: mongod --auth --config /etc/mongodb/mongodb.conf Step 4: Create additional users. Log in with the user administrator’s credentials and create additional users. See Add a User to a Database (page 386). If you need to disable authentication for any reason, restart the process without the authorization or keyFile option. Chapter 6. Security 360 use admin db.createUser( { user: "siteUserAdmin", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )