Shutdown MongoDB with auth enabled?

To shutdown MongoDB, you need to use shutdownServer() as in the below syntax −


First you need to switch to admin as shown below −

use admin;

Here, we switched to admin −

> use admin;
switched to db admin

Following is the query to shutdown server −

> db.shutdownServer();

This will produce the following output −

server should be down...
2020-01-07T22:40:31.295+0530 I NETWORK [js] trying reconnect to failed
2020-01-07T22:40:32.326+0530 I NETWORK [js] reconnect failed failed

Updated on: 01-Apr-2020


Kickstart Your Career

Get certified by completing the course

Get Started