MongoDB Plugin Design: Introduction: Difference between revisions
Jump to navigation
Jump to search
MongoDB Plugin Design: Introduction (view source)
Revision as of 08:18, 24 November 2010
, 24 November 2010Reverted edits by Upazixorys (Talk); changed back to last version by BobS
Upazixorys (talk | contribs) No edit summary |
m (Reverted edits by Upazixorys (Talk); changed back to last version by BobS) |
||
Line 1: | Line 1: | ||
{{Nav MongoDB Plugin Design}} | {{Nav MongoDB Plugin Design}} | ||
'''''MongoDB''''' | '''''MongoDB''''' | ||
Line 37: | Line 36: | ||
|- | |- | ||
| | | | ||
<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 | ||
</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 51: | Line 50: | ||
auth = true # authorization required | auth = true # authorization required | ||
verbose = true # to disable, comment out. | verbose = true # to disable, comment out. | ||
</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: | ||
|- | |- | ||
| | | | ||
<pre> | |||
mongo.exe admin | mongo.exe admin | ||
</pre> | |||
| | | | ||
<pre> | |||
mongo.exe --username root --password root admin | mongo.exe --username root --password root admin | ||
</pre> | |||
|} | |} | ||
Line 92: | Line 91: | ||
| | | | ||
'''''No-authentication'':''' | '''''No-authentication'':''' | ||
<pre> | |||
mongo.exe --eval | mongo.exe --eval "db.getSisterDB('admin').shutdownServer()" | ||
</pre> | |||
|- | |- | ||
| | | | ||
'''''Authentication'':''' | '''''Authentication'':''' | ||
<pre> | |||
mongo.exe --username root --password root admin --eval | mongo.exe --username root --password root admin --eval "db.shutdownServer()" | ||
</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'':''' | ||
<pre> | |||
$connection = new Mongo(); // connect | $connection = new Mongo(); // connect | ||
$db = $connection- | $db = $connection->uniform_server; // select (create) a database | ||
</pre> | |||
|- | |- | ||
| | | | ||
'''''Authentication'':''' | '''''Authentication'':''' | ||
<pre> | |||
$connection = new Mongo( | $connection = new Mongo("mongodb://root:root@localhost:27017"); | ||
$db = $connection- | $db = $connection->admin; // select (create) a database | ||
</pre> | |||
|} | |} | ||
'''''Note'':''' | '''''Note'':''' | ||
Line 146: | Line 145: | ||
| | | | ||
'''''Enter following into client'':''' | '''''Enter following into client'':''' | ||
<pre> | |||
use admin | use admin | ||
db.addUser( | db.addUser("name", "password") | ||
</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: | ||
<pre> | |||
db.authenticate( | db.authenticate("name", "password") | ||
</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'':''' | ||
<pre> | |||
use newdatabase | use newdatabase | ||
db.addUser( | db.addUser("fred", "fred123") | ||
</pre> | |||
|} | |} | ||
Line 180: | Line 179: | ||
Select the database and type this command: | Select the database and type this command: | ||
<pre> | |||
db.system.users.find() | db.system.users.find() | ||
</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: | ||
<pre> | |||
use admin | use admin | ||
db.addUser( | db.addUser("root", "new_password") | ||
</pre> | |||
Line 199: | Line 198: | ||
=== mongod.exe --help === | === mongod.exe --help === | ||
<pre> | |||
Allowed options: | Allowed options: | ||
Line 247: | Line 246: | ||
--service start mongodb service | --service start mongodb service | ||
...... | ...... | ||
</pre> | |||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
=== mongo.exe --help === | === mongo.exe --help === | ||
<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 | ||
</pre> | |||
== Summary == | == Summary == |