Changes

Jump to navigation Jump to search
693 bytes added ,  23:33, 8 April 2016
Line 73: Line 73:  
  <nowiki>security:
 
  <nowiki>security:
 
   authorization: enabled</nowiki>
 
   authorization: enabled</nowiki>
==== Modify user roles ====
+
==== Add user roles ====
  <nowiki>db.updateUser(
+
  <nowiki>use reporting
  "<username>",
+
db.grantRolesToUser(
  {
+
    "reportsUser",
    customData : { <any information> },
+
    [
    roles : [
+
      { role: "read", db: "accounts" }
              { role: "<role>", db: "<database>" } | "<role>",
+
     ]
              ...
  −
            ],
  −
    pwd: "<cleartext password>"
  −
    },
  −
     writeConcern: { <write concern> }
   
)</nowiki>
 
)</nowiki>
 +
==== Revoke user roles ====
 +
<nowiki>use reporting
 +
db.revokeRolesFromUser(
 +
    "reportsUser",
 +
    [
 +
      { role: "readWrite", db: "accounts" }
 +
    ]
 +
)</nowiki>
 +
 +
==== Create User ====
 +
<nowiki>use test
 +
db.createUser(
 +
    {
 +
      user: "tester",
 +
      pwd: "password",
 +
      roles: [
 +
        { role: "read", db: "test1" },
 +
        { role: "read", db: "test2" },
 +
        { role: "read", db: "test3" },
 +
        { role: "readWrite", db: "test" }
 +
      ]
 +
    }
 +
);</nowiki>
 +
or
 +
<nowiki>use products
 +
db.addUser( { user: "Alice",
 +
              pwd: "Moon1234",
 +
              roles: [ "readWrite", "dbAdmin" ]
 +
            } )</nowiki>
 +
or
 +
<nowiki>db.createUser(
 +
...        {
 +
...          user: "....",
 +
...          pwd: ".........",
 +
...          roles: [ "readWrite" ]
 +
...        }
 +
... )
 +
</nowiki>
 +
 +
==== Drop User ====
 +
<nowiki>db.dropUser(username)}</nowiki>
 +
 
=== Enable remote connections ===
 
=== Enable remote connections ===
 
* Edit /etc/mongodb.conf
 
* Edit /etc/mongodb.conf
 
* Add the ip's you whish to enable for remote access to bind_ip separated by ',' (Dont remove 127.0.0.1!!)
 
* Add the ip's you whish to enable for remote access to bind_ip separated by ',' (Dont remove 127.0.0.1!!)
  bind_ip = 127.0.0.1,192.168.56.10
+
  bind_ip = 127.0.0.1,192.168.56.222
 +
 
 
=== Disable Transparent Huge Pages (THP) ===
 
=== Disable Transparent Huge Pages (THP) ===
 
Create the init.d script.<br />
 
Create the init.d script.<br />

Navigation menu