mongodump -h 127.0.0.1:27017 -u "DB_USER" -p "PASSWORD" --db DB_NAME --archive=$HOME/backup/dump.gz --gzip
As a root user, no auth.
mongorestore --host=127.0.0.1 --gzip --archive=dump.gz
Selecte the DB_NAME
db.createUser(
{
user: "DB_USER",
pwd: "PASSWORD",
roles: [
{ role: "readWrite", db: "DB_NAME" }
]
}
)