Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
MongoDB shutdown option is unavailable? How to get it?
If the MongoDB shutdown option is unavailable, you need to switch to the admin database first. The shutdownServer() method requires administrative privileges and can only be executed from the admin database context.
Syntax
use admin db.shutdownServer()
Step 1: Switch to Admin Database
First, connect to the admin database ?
use admin
switched to db admin
Step 2: Execute Shutdown Command
Now run the shutdown command ?
db.shutdownServer()
server should be down... 2019-04-22T19:11:40.949+0530 I NETWORK [js] trying reconnect to 127.0.0.1:27017 failed 2019-04-22T19:11:42.197+0530 I NETWORK [js] reconnect 127.0.0.1:27017 failed failed
Key Points
- The
shutdownServer()method only works from the admin database. - You must have administrative privileges to shut down the MongoDB server.
- The reconnection failures in the output confirm the server has shut down successfully.
Conclusion
To access MongoDB's shutdown option, switch to the admin database using use admin, then execute db.shutdownServer(). This method requires admin privileges and will gracefully shut down the MongoDB server.
Advertisements
