nativeInstallerdreamfactory

Modify the default MongoDB root password

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). Learn more.

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 installdir/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 installdir
    $ sudo installdir/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 installdir/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 installdir
    $ sudo installdir/ctlscript.sh restart mongodb