MongoDB running but can't connect using shell

前端 未结 17 1740
甜味超标
甜味超标 2020-12-23 16:45

CentOS 5.x Linux with MongoDB 2.0.1 (tried main and legacy-static)

MongoDB is running:

root     31664  1.5  1.4  81848 11148 ?        Sl   18:40   0:         


        
17条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 17:20

    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 ;)

提交回复
热议问题