In order to enable database security, you need to start the mongod instance without security, create at least one user in the authentication database with the userAdminAnyDatabase role and restart mongod with security enabled. You can then authenticate as the new admin user and create additional users and make assignments as needed.
Here are the detailed steps you should follow to enable database security:
- Stop the local mongod instance if running. Restart it without security. This can be done by changing the security.authorization parameter in the mongod.conf file (mongod.cfg in Windows) to disabled. Alternatively, start mongod manually from Command Prompt using the --noauth option. If using Command Prompt, you also need to supply the --dbpath argument, needed to tell MongoDB where its database files are located.
Here is an example on an Ubuntu 18.04 server:
- You can now get into the mongo shell and create a new admin user. Here is an example of the...