zoukankan      html  css  js  c++  java
  • 权限管理

    切换用户;
    use admin
    db.auth("myClusterwideAdmin_user","admin123");
    建库,写入数据;
    use products;
    db.products.insertOne( { _id: 10, item: "box", qty: 20 } );
    db.auth("products_admin","admin123");
    db.products.save({item: "box", qty: 20 });
    db.createUser(
       {
         user: "products_admin",
         pwd: "admin123",
        roles: [ "readWrite", "dbAdmin" ]
       }
    );
    Successfully added user: { "user" : "products_admin", "roles" : [ "readWrite", "dbAdmin" ] }
    
    
    myreplSet:PRIMARY> use products
    switched to db products
    myreplSet:PRIMARY> db.createUser(
    ...    {
    ...      user: "products_admin",
    ...      pwd: "admin123",
    ...     roles: [ "readWrite", "dbAdmin" ]
    ...    }
    ... );
    Successfully added user: { "user" : "products_admin", "roles" : [ "readWrite", "dbAdmin" ] }
    myreplSet:PRIMARY> use products
    switched to db products
    myreplSet:PRIMARY> db.getRoles();
    [ ]
    myreplSet:PRIMARY> db.getUsers();
    [
    	{
    		"_id" : "products.products_admin",
    		"user" : "products_admin",
    		"db" : "products",
    		"roles" : [
    			{
    				"role" : "readWrite",
    				"db" : "products"
    			},
    			{
    				"role" : "dbAdmin",
    				"db" : "products"
    			}
    		]
    	}
    ]
    myreplSet:PRIMARY>
    
    db.collection.drop()
    
    Studio 3T for MongoDB连接51.212复制集
    [
        #DirectConection
        Authentication Mode - Basic(MONGODB-CR or SCEAM-SHA-1)
        192.168.2.51:27017 -u products_admin -p admin123
        192.168.2.212:27017 -u products_admin -p admin123
        Authentication DB - products
    ]
    [
        #Replica Set Or Sharded Cluster
        192.168.2.51:27017
        192.168.2.212:27017
        Authentication Mode - Basic(MONGODB-CR or SCEAM-SHA-1)
        -u products_admin -p admin123
        Read Preference -Nearest
        Authentication DB - products
    
        C:WindowsSystem32driversetchosts
        +
        192.168.2.51 hadoop1
        192.168.2.212 hadoop2
    ]
    
    
    show collections;
    db.createCollection('direct_ad_consume');
    db.createCollection('sem_z_cashier');
    

      

  • 相关阅读:
    仿当当网鼠标经过图片翻转
    静态随鼠标移动的Tip
    Weblogic免项目名
    weblogic中文乱码问题
    IE6下的{clear:both}出现怪异的空白
    动态随鼠标移动的Tip
    base标签在ie6下的恶心问题
    javascript中for和for in 区别
    jQuery性能优化<<转>>
    Ant项目打包脚本
  • 原文地址:https://www.cnblogs.com/rsapaper/p/7881046.html
Copyright © 2011-2022 走看看