Can I restart a MongoDB server through the mongo CLI client?
You can't stop and start (restart) it from the client. As i.kimiko already mentioned, you can shut it down on your client with db.shutdownServer()
through a mongo shell database methods documentation 3.6.0
But then you'd still have to connect to the server and restart it from there with sudo service mongodb start
for example.
You can shutdown server via client.
mongo --host "hostname where server or IP" --port "port of mondodb server" --username "username" --password "password"
use admin
db.shutdownServer()
link to documentation about db.shutdownServer() mongodb 3.6.0
After that you may up that server via other service\tool (from a host machine when a mongodb server installed), like cron for example or using systemd unit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With