zoukankan      html  css  js  c++  java
  • mongodb连接错误原因及处理方法

    #新安装mongo后,第二次连接出现下面错误
    root@jeff:/opt/program/python# mongo
    MongoDB shell version: 2.0.6
    connecting to: test
    Thu Apr 11 10:04:39 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
    exception: connect failed

    原因:

    创建数据库时,是自己指定的数据库,

    当第二次连接时,如果使用的是自动加载服务,就会出现不能连接的错误,如上面情况所述。

    解决方法:

    1、可以使用mongod --dbpath /path/to/your/dbdata

    2、如果相隔时间较长,忘记了上次指定的数据库path(这种情况很容易发生),那么采用下面的方法:

    删除  /var/lib/mongodb/mongod.lock 文件

    重启  sudo /etc/init.d/mongodb restart

    即可:

    #删除
    root@jeff:/opt# rm /var/lib/mongodb/mongod.lock 
    
    #重启:
    root@jeff:/opt# /etc/init.d/mongodb restart
    Rather than invoking init scripts through /etc/init.d, use the service(8)
    utility, e.g. service mongodb restart
    
    Since the script you are attempting to invoke has been converted to an
    Upstart job, you may also use the stop(8) and then start(8) utilities,
    e.g. stop mongodb ; start mongodb. The restart(8) utility is also available.
    mongodb start/running, process 12569
    
    #连接:
    root@jeff:/opt# mongo
    MongoDB shell version: 2.0.6
    connecting to: test
    > 
  • 相关阅读:
    洛谷 P2260 [清华集训2012]模积和 || bzoj2956
    Mass Change Queries Codeforces
    Single-use Stones Codeforces
    洛谷 P4503 [CTSC2014]企鹅QQ
    洛谷 P1463 [HAOI2007]反素数
    Bear and Tower of Cubes Codeforces
    洛谷 P1593 因子和 || Sumdiv POJ
    记一次服务器inodes数报警的事件
    MySQL参数详解
    Django基础流程
  • 原文地址:https://www.cnblogs.com/thinbottle/p/3013796.html
Copyright © 2011-2022 走看看