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

前端 未结 13 2107
后悔当初
后悔当初 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:29

    This is actually not an error... What happens here is that Mongo relies on a daemon in order to run the local database server, so in order to "fire up" the mongo server in your shell, you have to start the mongo service first.

    For Fedora Linux (wich is the Distro I use) You have to run these commands:

    1 sudo service mongod start
    2 mongo
    

    And there you have it! the server is going to run. Now, If you want Mongo service to Start when the system boots then you have to run:

    sudo chkconfig --levels 235 mongod on
    

    And that's all! If you do that, now in the shell you just have to type mongo in order to start the server but that's pretty much it, the problem is you have to start the SERVICE first and then the SERVER :)

    P.S. The commands I posted might work on other linux distros as well, not just in fedora... In case not maybe you have to tweak some words depending on the distro you're using ;)

提交回复
热议问题