Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

前端 未结 27 2564
孤街浪徒
孤街浪徒 2020-12-12 15:06

while trying this mongo command in ubuntu I am getting this error.

    ritzysystem@ritzysystem-Satellite-L55-A:~$ mongo
    MongoDB shell version: 2.6.1
             


        
27条回答
  •  再見小時候
    2020-12-12 15:18

    Do this:

    sudo rm /var/lib/mongodb/mongod.lock
    sudo service mongod restart
    

    If you are on Ubuntu 16.04 which you can figure out by runnign this:

    lsb_release -a
    

    You need to Create a new file at /lib/systemd/system/mongod.service with the following contents:

    [Unit]
    Description=High-performance, schema-free document-oriented database
    After=network.target
    Documentation=https://docs.mongodb.org/manual
    
    [Service]
    User=mongodb
    Group=mongodb
    ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
    
    [Install]
    WantedBy=multi-user.target
    

提交回复
热议问题