Home  >  Q&A  >  body text

ubuntu - mongodb链接问题。

flytutu@flytutu-X550JK:~$ mongo
MongoDB shell version: 3.2.6
connecting to: test
2016-06-02T12:30:02.242+0800 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-06-02T12:30:02.242+0800 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

利用终端链接,出现了这个问题,网上的方法也尝试过,没有成功,求解决方法。

淡淡烟草味淡淡烟草味2727 days ago733

reply all(4)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:21:20

    Your mongo has not started. I don’t know how you installed it. The following startup method is for reference only

    /usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --fork --logpath=/usr/local/mongodb/mg.log

    reply
    0
  • PHP中文网

    PHP中文网2017-05-02 09:21:20

    http://chenzhou123520.iteye.com/blog/1582179

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-02 09:21:20

    First of all, during the installation process, it is recommended to install from the software source. Please refer to the installation documentation for specific steps. It also talks about how to start after the installation is completed.
    Second, check the listening address in the configuration file:

    sudo vim /etc/mongod.conf
    

    If necessary, change bindIp to the address you need to monitor (and then restart).
    The method mentioned by @prolifes can be used in a test environment, but it is not recommended in a production environment. A few reasons:

    • This is when you start the mongod的,安全方面有违最佳实践,特别是你当前使用的是rootuser as your current user.

    • The init.d startup script contains some server optimization parameters, such as disabling numa. Direct startup will cause some performance problems in the future.

    • All the reasons to use a daemon

    reply
    0
  • 高洛峰

    高洛峰2017-05-02 09:21:20

    http://blog.csdn.net/wangli61...

    reply
    0
  • Cancelreply