The latest version of MongoDB does most of needs except one thing for now. After installing MongoDB on Ubuntu 16.04.x then run the commands as follows:
First create mongodb.service file by follow command :
第一步:
sudo vim /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
Then , run these commands on the terminal one by one:
依次输入下面指令
sudo systemctl enable mongod.service sudo systemctl daemon-reload sudo service mongod start
mongo启动