MongoDB Plugin Design: Introduction: Difference between revisions
MongoDB Plugin Design: Introduction (view source)
Revision as of 01:18, 24 November 2010
, 24 November 2010no edit summary
(Punctuation and grammatical changes; some clarification.) |
Upazixorys (talk | contribs) 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> | |||
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> | |||
| | | | ||
<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 50: | Line 51: | ||
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 72: | Line 73: | ||
|- | |- | ||
| | | | ||
<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 91: | Line 92: | ||
| | | | ||
'''''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 115: | Line 116: | ||
| | | | ||
'''''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 145: | Line 146: | ||
| | | | ||
'''''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 169: | Line 170: | ||
| | | | ||
'''''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 179: | Line 180: | ||
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 198: | Line 199: | ||
=== mongod.exe --help === | === mongod.exe --help === | ||
<pre> | |||
Allowed options: | Allowed options: | ||
Line 246: | Line 247: | ||
--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 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> | |||
== Summary == | == Summary == |