Difference between revisions of "MongoDB StartingMongoDB"
(Created page with "Main Page >> MongoDB >>MongoDB Workbook >> Starting MongoDB Once you have logged on to mi-linux.wlv.ac.uk you can then access MongoDB ==...") |
|||
(14 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
Once you have logged on to mi-linux.wlv.ac.uk you can then access MongoDB | Once you have logged on to mi-linux.wlv.ac.uk you can then access MongoDB | ||
− | == | + | == Using MongoDB == |
− | MongoDB can be started in several ways | + | Once logged into the server, you should see the Linux prompt: |
+ | |||
+ | <pre style="color:blue"> | ||
+ | csl-student$ | ||
+ | </pre> | ||
+ | |||
+ | == Registering for an Account == | ||
+ | |||
+ | If you have not used MongoDB before, you will need to register for an account. | ||
+ | |||
+ | Assuming you have already logged into mi-linux, type: | ||
+ | |||
+ | /home/oracle/addMongo | ||
+ | |||
+ | You will be prompted for which module you are taking that uses MongoDB. Pick the appropriate one, then you will be registered for MongoDB. The default password is your student number, with ''MDB'' appended. '''You are strongly advised to change this when you first login'''. | ||
+ | |||
+ | Note: you can also use the command above to reset your password, if you change it and forget what it is! | ||
+ | |||
+ | Once registered, MongoDB can be started in several ways from the Linux prompt: | ||
=== First time === | === First time === | ||
− | + | To start MongoDB type: | |
runMongo | runMongo | ||
− | This runs with | + | This runs with the default password, that should be changed when you first login (see below). |
+ | |||
+ | The system should respond with: | ||
+ | |||
+ | <pre style="color:blue"> | ||
+ | Hello: yourStudentNumber | ||
+ | MongoDB shell version: 3.2.8 | ||
+ | connecting to: 127.0.0.1:27017/dbyourStudentNumber | ||
+ | > | ||
+ | </pre> | ||
+ | |||
+ | Any MongoDB command should be typed in at the '''>''' prompt. | ||
=== With Password === | === With Password === | ||
− | Once you have changed your password: | + | Once you have changed your password, use instead: |
runMongo yourPassword | runMongo yourPassword | ||
+ | Note: only run this from the Linux command line, not within MongoDB itself. | ||
+ | |||
+ | === Using mongo directly === | ||
+ | |||
+ | ''runMongo'' is a script file setup for your convenience that runs the '''mongo''' command and logs you into your own database. | ||
− | + | If you need to use any of the other mongo options for any reason, you will need to run '''mongo''' directly: | |
− | + | mongo dbYourStudentNumber --port 27017 -u yourStudentNumber -p yourMongoPassword -whatever_options_are_required | |
− | + | For example, if yourStudentNumber is ''1612345'' and MongoDB password is ''myMongoPwd'' then you would login as: | |
− | mongo | + | mongo db1612345 --port 27017 -u 1612345 -p myMongoPwd -whatever_options_are_required |
== Changing Password == | == Changing Password == | ||
Line 41: | Line 75: | ||
− | Replacing myStudentNumber with your University student number and | + | Replacing '''myStudentNumber''' with your ''University'' student number and '''myNewPassword''' with your new password. |
Note, the function names in MongoDB are <b>case sensitive</b>. | Note, the function names in MongoDB are <b>case sensitive</b>. | ||
+ | |||
+ | |||
+ | == Exiting MongoDB == | ||
+ | |||
+ | To leave MongoDB type: | ||
+ | |||
+ | exit | ||
== Next Step == | == Next Step == | ||
− | [[ | + | [[MongoDB_Getting_Started|Return]] to Getting Started. |
Latest revision as of 10:35, 15 March 2021
Main Page >> MongoDB >>MongoDB Workbook >> Starting MongoDB
Once you have logged on to mi-linux.wlv.ac.uk you can then access MongoDB
Using MongoDB
Once logged into the server, you should see the Linux prompt:
csl-student$
Registering for an Account
If you have not used MongoDB before, you will need to register for an account.
Assuming you have already logged into mi-linux, type:
/home/oracle/addMongo
You will be prompted for which module you are taking that uses MongoDB. Pick the appropriate one, then you will be registered for MongoDB. The default password is your student number, with MDB appended. You are strongly advised to change this when you first login.
Note: you can also use the command above to reset your password, if you change it and forget what it is!
Once registered, MongoDB can be started in several ways from the Linux prompt:
First time
To start MongoDB type:
runMongo
This runs with the default password, that should be changed when you first login (see below).
The system should respond with:
Hello: yourStudentNumber MongoDB shell version: 3.2.8 connecting to: 127.0.0.1:27017/dbyourStudentNumber >
Any MongoDB command should be typed in at the > prompt.
With Password
Once you have changed your password, use instead:
runMongo yourPassword
Note: only run this from the Linux command line, not within MongoDB itself.
Using mongo directly
runMongo is a script file setup for your convenience that runs the mongo command and logs you into your own database.
If you need to use any of the other mongo options for any reason, you will need to run mongo directly:
mongo dbYourStudentNumber --port 27017 -u yourStudentNumber -p yourMongoPassword -whatever_options_are_required
For example, if yourStudentNumber is 1612345 and MongoDB password is myMongoPwd then you would login as:
mongo db1612345 --port 27017 -u 1612345 -p myMongoPwd -whatever_options_are_required
Changing Password
Once you have logged into MongoDB successfully you can change the default password:
db.updateUser("myStudentNumber", { pwd: "myNewPassword", } );
Replacing myStudentNumber with your University student number and myNewPassword with your new password.
Note, the function names in MongoDB are case sensitive.
Exiting MongoDB
To leave MongoDB type:
exit
Next Step
Return to Getting Started.