Ubuntu安装MongoDB 开启服务

2018-09-18  本文已影响158人  GaoYangTongXue丶

在ubuntu下安装MongoDB的步骤:

  • 1.运行"apt-get install mongo"如果遇到找不到安装包的话运行"apt-get update"
  • 2.这时装好以后应该会自动运行mongod程序,通过"pgrep mongo -l "查看进程是否已经启动
  • 3.在终端输入"mongo",然后回车进入数据库

按照上面的步骤就可以使用了。当我装好以后,用了一下,等再次开机使用的时候,报错了。

错误为:Failed to start mongod.service:until not found此刻的心情,一万个CNM。。。。

看了网上的一些帖子找到了解决方法:

解决方法:

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

上一篇 下一篇

猜你喜欢

热点阅读