MongoDB Plugin Design: Introduction: Difference between revisions

no edit summary
(Punctuation and grammatical changes; some clarification.)
No edit summary
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 36: Line 37:
|-
|-
|
|
<pre>
&lt;pre&gt;
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 42: Line 43:
noauth  = true            # no authorization
noauth  = true            # no authorization
verbose = true  
verbose = true  
</pre>
&lt;/pre&gt;
|
|
<pre>
&lt;pre&gt;
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 50: Line 51:
auth    = true            # authorization required
auth    = true            # authorization required
verbose = true            # to disable, comment out.
verbose = true            # to disable, comment out.
</pre>
&lt;/pre&gt;
|}
|}
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 72: Line 73:
|-
|-
|
|
<pre>
&lt;pre&gt;
mongo.exe admin
mongo.exe admin
</pre>
&lt;/pre&gt;
|
|
<pre>
&lt;pre&gt;
mongo.exe --username root --password root admin
mongo.exe --username root --password root admin
</pre>
&lt;/pre&gt;
|}
|}


Line 91: Line 92:
|
|
'''''No-authentication'':'''
'''''No-authentication'':'''
<pre>
&lt;pre&gt;
mongo.exe  --eval "db.getSisterDB('admin').shutdownServer()"
mongo.exe  --eval &quot;db.getSisterDB('admin').shutdownServer()&quot;
</pre>
&lt;/pre&gt;
|-
|-
|
|
'''''Authentication'':'''
'''''Authentication'':'''
<pre>
&lt;pre&gt;
mongo.exe  --username root --password root admin --eval "db.shutdownServer()"
mongo.exe  --username root --password root admin --eval &quot;db.shutdownServer()&quot;
</pre>
&lt;/pre&gt;
|}
|}
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 115: Line 116:
|
|
'''''No-authentication'':'''
'''''No-authentication'':'''
<pre>
&lt;pre&gt;
$connection = new Mongo();              // connect
$connection = new Mongo();              // connect
$db = $connection->uniform_server;      // select (create) a database
$db = $connection-&gt;uniform_server;      // select (create) a database
</pre>
&lt;/pre&gt;
|-
|-
|
|
'''''Authentication'':'''
'''''Authentication'':'''
<pre>
&lt;pre&gt;
$connection = new Mongo("mongodb://root:root@localhost:27017");
$connection = new Mongo(&quot;mongodb://root:root@localhost:27017&quot;);
$db = $connection->admin;        // select (create) a database
$db = $connection-&gt;admin;        // select (create) a database
</pre>
&lt;/pre&gt;
|}
|}
'''''Note'':'''
'''''Note'':'''
Line 145: Line 146:
|
|
'''''Enter following into client'':'''
'''''Enter following into client'':'''
<pre>
&lt;pre&gt;
use admin
use admin
db.addUser("name", "password")
db.addUser(&quot;name&quot;, &quot;password&quot;)
</pre>
&lt;/pre&gt;
|}  
|}  
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:
<pre>
&lt;pre&gt;
db.authenticate("name", "password")
db.authenticate(&quot;name&quot;, &quot;password&quot;)
</pre>
&lt;/pre&gt;
'''''Note 1'':''' Uniform Server defaults are name='''root''' password='''root'''
'''''Note 1'':''' Uniform Server defaults are name='''root''' password='''root'''


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


Line 179: Line 180:


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


=== 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:
<pre>
&lt;pre&gt;
use admin
use admin
db.addUser("root", "new_password")
db.addUser(&quot;root&quot;, &quot;new_password&quot;)
</pre>
&lt;/pre&gt;




Line 198: Line 199:


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


Line 246: Line 247:
   --service                start mongodb service
   --service                start mongodb service
  ......
  ......
</pre>
&lt;/pre&gt;
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== mongo.exe --help ===
=== mongo.exe --help ===
<pre>
&lt;pre&gt;
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 271: Line 272:
             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
</pre>
&lt;/pre&gt;


== Summary ==
== Summary ==
322

edits