在 Debian 上重启 MongoDB,取决于你是通过 系统包(apt) 还是 其他方式 安装的。最常见的是使用 systemd。
sudo systemctl restart mongod
查看状态:
sudo systemctl status mongod
开机自启(如未设置):
sudo systemctl enable mongod
sudo service mongod restart
某些版本包名为 mongodb 或自定义名:
sudo systemctl restart mongodb
可以用下面命令确认服务名:
systemctl list-units --type=service | grep mongo
如果没用 systemd:
mongod --config /etc/mongod.conf --shutdown
mongod --config /etc/mongod.conf
sudorestart 失败可看日志sudo tail -n 50 /var/log/mongodb/mongod.log
如果你告诉我 Debian 版本 和 MongoDB 安装方式,我可以给你更精确命令。