Modify the default MongoDB root password
Modify the MongoDB root password
You can modify the MongoDB password using the following command at the shell prompt:
$ mongo admin --username root --password YOURPASSWORD
MongoDB shell version: 2.4.8
connecting to: 127.0.0.1:27017/admin
> db = db.getSiblingDB('admin')
admin
> db.changeUserPassword("root", "NEWPASSWORD")
> exit
NOTE: Remember that both YOURPASSWORD and NEWPASSWORD are placeholders. Replace them with your current password and with the new password you want to set.
Reset the MongoDB root password
You can reset the administrator password by following the steps below:
-
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