Can I restart a MongoDB server through the mongo CLI client?
Can I restart mongodb server through mongo shell?
Asked Answered
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.
Ok, got it. Use: mongo --host <hostname> --port <port> --username <username> --password <password> -> use admin -> db.shutdownServer() –
Rodgerrodgers
© 2022 - 2024 — McMap. All rights reserved.