试试两种解决方案
sudo systemctl unmask mongodb
sudo service mongod start
或者
1创建配置文件:
sudo nano /etc/systemd/system/mongodb.service
2复制代码
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
3按ctrl+X退出
4启动服务
sudo systemctl start mongodb
sudo systemctl status mongodb
5让它永久启动
sudo systemctl enable mongodb