How to shutdown MongoDB instance from MongoDB Shell?

For some cases we may have access to database instance of MongoDB as DBA. But we may not have access to Linux or Windows box to shutdown the MongoDB service or MongoDB instance. To Shutdown the MongoDB instance you should be able to log in to “admin” database.  If your MongoDB instance is running with “auth” mode you really need a password and username. In this demo I assume MongoDB instance is not running with “auth” mode.

I login to MongoDB shell first.

mongo

Then I change the database to admin database.

use admin

Now I’m going to run that command. This command will shutdown the instance hence think twice before you use it.

db.runCommand( { shutdown : 1 } );

That is like adventure to a DBA because your database will crash if you don’t have any replication plan. 😉

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s