couldn't connect to server 127.0.0.1 shell/mongo.js

前端 未结 13 2112
后悔当初
后悔当初 2020-11-29 19:07

when i setup mongodb in my ubuntu , i try : ./mongo it show this error :

 couldn\'t connect to server 127.0.0.1 shell/mongo.js

so what can

13条回答
  •  无人及你
    2020-11-29 19:33

    First you have to make sure that all the files and directories in your /var/lib/mongodb/ folder (or whichever folder dbpath points to) belong to the mongodb user and mongodb group.

    cd /var/lib/mongodb/
    sudo chown mongodb filename.*
    sudo chgrp mongodb filename.*
    sudo chown -R mongodb directory
    sudo chgrp -R mongodb directory
    

    (Replace filename and directory with their respective names)

    Then you can remove the lock, repair the database and restart the daemon as other people already mentioned:

    sudo rm /var/lib/mongodb/mongod.lock   
    sudo -u mongodb mongod -f /etc/mongodb.conf --repair 
    sudo service mongodb start
    

提交回复
热议问题