https://blog.csdn.net/weixin_39198406/article/details/83656943
1. 执行以下命令:
sudo vim /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. 执行以下命令:
sudo systemctl enable mongod.service
sudo systemctl daemon-reload
sudo service mongod start