zoukankan      html  css  js  c++  java
  • mongo__4.23

    也支持同 mysql 一样的读取启动配置文件的方式来启动数据库,配置文件的内容如下
        [root@localhost bin]# cat /etc/mongodb.cnf
        dbpath=/data/db/
    启动时加上”-f”参数,并指向配置文件即可
        [root@localhost bin]# ./mongod -f /etc/mongodb.cnf  
        Mon May 28 18:27:18 [initandlisten] MongoDB starting : pid=18481
        dbpath=/data/db/ 32-bit
        ......
        Mon May 28 18:27:18 [initandlisten] waiting for connections on port 27017
        Mon May 28 18:27:18 [websvr] web admin interface listening on port 28017


    find() 来查询, 他返回一个任意结构的集合.
    实现上面同样的查询, 然后通过 while 来输出


      > var cursor = db.things.find();
      > while (cursor.hasNext()) printjson(cursor.next());
      { "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }
      { "_id" : ObjectId("4c2209fef3924d31102bd84b"), "x" : 3 }
      { "_id" : ObjectId("4c220a42f3924d31102bd856"), "x" : 4, "j" : 1 }
      { "_id" : ObjectId("4c220a42f3924d31102bd857"), "x" : 4, "j" : 2 }
      { "_id" : ObjectId("4c220a42f3924d31102bd858"), "x" : 4, "j" : 3 }
      { "_id" : ObjectId("4c220a42f3924d31102bd859"), "x" : 4, "j" : 4 }
      { "_id" : ObjectId("4c220a42f3924d31102bd85a"), "x" : 4, "j" : 5 }

  • 相关阅读:
    ElasticSearch原理
    redis master配置了密码进行主从同步
    redis sentinel 高可用(HA)方案部署,及python应用示例
    Linux Redis集群搭建与集群客户端实现
    字符串倒序
    单链表反转
    【python】面试常考数据结构算法
    面试中的排序算法总结
    Memcached 真的过时了吗?
    Activity生命周期
  • 原文地址:https://www.cnblogs.com/ldms/p/3038026.html
Copyright © 2011-2022 走看看