MongoDB Plugin Design: Introduction: Difference between revisions

m
Reverted edits by Upazixorys (Talk); changed back to last version by BobS
No edit summary
m (Reverted edits by Upazixorys (Talk); changed back to last version by BobS)
 
Line 1: Line 1:
=[http://odygobyciqi.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
{{Nav MongoDB Plugin Design}}
{{Nav MongoDB Plugin Design}}
'''''MongoDB'''''
'''''MongoDB'''''
Line 37: Line 36:
|-
|-
|
|
<pre>
<pre>
dbpath  = ../data/mongodb  # Path to db  
dbpath  = ../data/mongodb  # Path to db  
bind_ip = 127.0.0.1        # Localhost
bind_ip = 127.0.0.1        # Localhost
Line 43: Line 42:
noauth  = true            # no authorization
noauth  = true            # no authorization
verbose = true  
verbose = true  
&lt;/pre&gt;
</pre>
|
|
&lt;pre&gt;
<pre>
dbpath  = ../data/mongodb  # Path to db  
dbpath  = ../data/mongodb  # Path to db  
bind_ip = 127.0.0.1        # Localhost
bind_ip = 127.0.0.1        # Localhost
Line 51: Line 50:
auth    = true            # authorization required
auth    = true            # authorization required
verbose = true            # to disable, comment out.
verbose = true            # to disable, comment out.
&lt;/pre&gt;
</pre>
|}
|}
With the exception of dbpath and auth all parameters are default values.
With the exception of dbpath and auth all parameters are default values.
Line 73: Line 72:
|-
|-
|
|
&lt;pre&gt;
<pre>
mongo.exe admin
mongo.exe admin
&lt;/pre&gt;
</pre>
|
|
&lt;pre&gt;
<pre>
mongo.exe --username root --password root admin
mongo.exe --username root --password root admin
&lt;/pre&gt;
</pre>
|}
|}


Line 92: Line 91:
|
|
'''''No-authentication'':'''
'''''No-authentication'':'''
&lt;pre&gt;
<pre>
mongo.exe  --eval &quot;db.getSisterDB('admin').shutdownServer()&quot;
mongo.exe  --eval "db.getSisterDB('admin').shutdownServer()"
&lt;/pre&gt;
</pre>
|-
|-
|
|
'''''Authentication'':'''
'''''Authentication'':'''
&lt;pre&gt;
<pre>
mongo.exe  --username root --password root admin --eval &quot;db.shutdownServer()&quot;
mongo.exe  --username root --password root admin --eval "db.shutdownServer()"
&lt;/pre&gt;
</pre>
|}
|}
I have show two methods for selection the admin database, either by specifying it on the command-line or by getting the help method  db.getSisterDB('admin')  to select it.     
I have show two methods for selection the admin database, either by specifying it on the command-line or by getting the help method  db.getSisterDB('admin')  to select it.     
Line 116: Line 115:
|
|
'''''No-authentication'':'''
'''''No-authentication'':'''
&lt;pre&gt;
<pre>
$connection = new Mongo();              // connect
$connection = new Mongo();              // connect
$db = $connection-&gt;uniform_server;      // select (create) a database
$db = $connection->uniform_server;      // select (create) a database
&lt;/pre&gt;
</pre>
|-
|-
|
|
'''''Authentication'':'''
'''''Authentication'':'''
&lt;pre&gt;
<pre>
$connection = new Mongo(&quot;mongodb://root:root@localhost:27017&quot;);
$connection = new Mongo("mongodb://root:root@localhost:27017");
$db = $connection-&gt;admin;        // select (create) a database
$db = $connection->admin;        // select (create) a database
&lt;/pre&gt;
</pre>
|}
|}
'''''Note'':'''
'''''Note'':'''
Line 146: Line 145:
|
|
'''''Enter following into client'':'''
'''''Enter following into client'':'''
&lt;pre&gt;
<pre>
use admin
use admin
db.addUser(&quot;name&quot;, &quot;password&quot;)
db.addUser("name", "password")
&lt;/pre&gt;
</pre>
|}  
|}  
Authentication takes immediate effect. Further actions require authenticated access. With the current connection you can use explicit authentication by entering this line:
Authentication takes immediate effect. Further actions require authenticated access. With the current connection you can use explicit authentication by entering this line:
&lt;pre&gt;
<pre>
db.authenticate(&quot;name&quot;, &quot;password&quot;)
db.authenticate("name", "password")
&lt;/pre&gt;
</pre>
'''''Note 1'':''' Uniform Server defaults are name='''root''' password='''root'''
'''''Note 1'':''' Uniform Server defaults are name='''root''' password='''root'''


Line 170: Line 169:
|
|
'''''For example enter following into client'':'''
'''''For example enter following into client'':'''
&lt;pre&gt;
<pre>
use newdatabase
use newdatabase
db.addUser(&quot;fred&quot;, &quot;fred123&quot;)
db.addUser("fred", "fred123")
&lt;/pre&gt;
</pre>
|}
|}


Line 180: Line 179:


Select the database and type this command:
Select the database and type this command:
&lt;pre&gt;
<pre>
db.system.users.find()
db.system.users.find()
&lt;/pre&gt;
</pre>


=== Changing Passwords ===
=== Changing Passwords ===
If a user already exists, all that is required is to run addUser to change their password.
If a user already exists, all that is required is to run addUser to change their password.
Hence to change the default Admin requires:
Hence to change the default Admin requires:
&lt;pre&gt;
<pre>
use admin
use admin
db.addUser(&quot;root&quot;, &quot;new_password&quot;)
db.addUser("root", "new_password")
&lt;/pre&gt;
</pre>




Line 199: Line 198:


=== mongod.exe --help ===
=== mongod.exe --help ===
&lt;pre&gt;
<pre>
Allowed options:
Allowed options:


Line 247: Line 246:
   --service                start mongodb service
   --service                start mongodb service
  ......
  ......
&lt;/pre&gt;
</pre>
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== mongo.exe --help ===
=== mongo.exe --help ===
&lt;pre&gt;
<pre>
usage: mongo.exe [options] [db address] [file names (ending in .js)]
usage: mongo.exe [options] [db address] [file names (ending in .js)]
db address can be:
db address can be:
Line 272: Line 271:
             files have to end in .js
             files have to end in .js
             and will exit after unless --shell is specified
             and will exit after unless --shell is specified
&lt;/pre&gt;
</pre>


== Summary ==
== Summary ==