zoukankan      html  css  js  c++  java
  • MongoDB基础操作

    进入
    mongo.exe
    
    创建用户
    use admin
    db.createUser(
       {
         user: "root",
         pwd: "root",
         roles:
           [
             { role: "readWrite", db: "config" },
             "clusterAdmin"
           ]
       }
    )
    
    远程访问
    mongod.cfg
    net:
      port: 27017
      #bindIp: 127.0.0.1
      bindIp: 0.0.0.0
    
    
    
    MongoDB中每个数据库之间是相互独立的,都有独立的权限,正确的做法是使用root账号在【将要操作的数据库】中创建一个【子账号】,在用这个子账号连接mongo
    
    例如:
    >use admin
    switched to db admin
    >db.auth("root","123456")
    1
    >show dbs
    admin
    local
    testDB
    >use testDB
    switched to db testDB
    >db.createUser(
            {
                user:"usertest",
                pwd:"123456",
                roles:[{role:"dbOwner",db:"testBD"}]
            }
    )
    
    Successfully added user: {
      "user" : "usertest",
      "roles" : [
        {
          "role" : "dbOwner",
          "db" : "testDB"
        }
      ]
    }
  • 相关阅读:
    C#垃圾回收(GC)
    yum --enablerepo=elrepo-kernel install kernel-lt -y
    centos 查看版本
    linux 内核升级
    awk
    升级内核
    elerpo
    http://elrepo.org/tiki/tiki-index.php
    NO_TITLE
    MongoDB Find查询 1
  • 原文地址:https://www.cnblogs.com/song-wentao/p/10563883.html
Copyright © 2011-2022 走看看