美文网首页
Ubuntu安装MongoDB 开启服务

Ubuntu安装MongoDB 开启服务

作者: GaoYangTongXue丶 | 来源:发表于2018-09-18 22:47 被阅读158次

    在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

    相关文章

      网友评论

          本文标题:Ubuntu安装MongoDB 开启服务

          本文链接:https://www.haomeiwen.com/subject/rmnvnftx.html