Mongo: enabling user auth

By default, mongo runs with user auth disabled.

To enable it, do the following:

Create admin user

First, connect to admin database and create "admin" user (it can be named anything, does not necessarily need to be called "admin"):

Enable user auth in mongod.conf and restart mongod

In /etc/mongod.conf, make sure the following is present and restart mongod:

Connect to mongo shell with auth enabled

Create a non-admin user for database access

This one will create "phpunituser" with "readWrite" access to "phpunitdb" database. Make sure "use phpunitdb" is present before db.createUser(...):

Connect to mongo shell as non-admin user

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.