Ubuntu16.04下安装mongodb运行失败解决
亲测有效,2018.7.25
-
创建mongodb.service文件:
sudo nano /etc/systemd/system/mongodb.service
-
写入如下内容:
[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
- 现在可以启动服务并检查它的状态:
sudo systemctl start mongodb
sudo systemctl status mongodb
- 使其永久有效
sudo systemctl enable mongodb