Edit the /opt/bitnami/mongodb/mongodb.conf file and replace the following lines:
# Turn on/off security. Off is currently the default
# noauth = true
auth = true
# Disable the HTTP interface (Defaults to localhost:27018).
# nohttpinterface = true
setParameter = enableLocalhostAuthBypass=0
with:
# Turn on/off security. Off is currently the default
noauth = true
# auth = true
# Disable the HTTP interface (Defaults to localhost:27018).
# nohttpinterface = true
# setParameter = enableLocalhostAuthBypass=0
Restart the MongoDB server:
cd /opt/bitnami
sudo /opt/bitnami/ctlscript.sh restart mongodb
Create a new administrative user with a new password. Run the following commands to do so (remember to replace NEWPASSWORD with the new one you want to set):
mongo
> db = db.getSiblingDB('admin')
admin
> db.changeUserPassword("root", "NEWPASSWORD")
Revert the modifications made to /opt/bitnami/mongodb/mongodb.conf by replacing:
# Turn on/off security. Off is currently the default
noauth = true
# auth = true
# Disable the HTTP interface (Defaults to localhost:27018).
# nohttpinterface = true
# setParameter = enableLocalhostAuthBypass=0
with:
# Turn on/off security. Off is currently the default
# noauth = true
auth = true
# Disable the HTTP interface (Defaults to localhost:27018).
# nohttpinterface = true
setParameter = enableLocalhostAuthBypass=0
Restart the MongoDB server again:
cd /opt/bitnami
sudo /opt/bitnami/ctlscript.sh restart mongodb