Store Data in MongoDB help

Store Data in MongoDB help


Hey guys, I need help on the MongoDB - store data in MongoDB Ex 1 in C9.

I did Step 9 ‘npm install learnyoumongo -g’ fine, and saw the installation included mongoDB 2.2.8 installation. Then came the trouble :

Step 10 says install mongoDB, but the video clip says mondoDB already installed in C9 workspace, just need to create a file named solution.js, then type the command “mongod --version”. I followed that and got the following error:

audt:~/workspace $ mongod --version
bash: mongod: command not found

I decided to give Step 11 set up mongod alias a try by following the directions at

audt:~/workspace $ mkdir data
audt:~/workspace $ echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"' > mongod
audt:~/workspace $ chmod a+x mongod

This is what my workspace looks like after running the above alias setup:

audt:~/workspace $ ls -lrF
total 28
-rw-r--r-- 1 ubuntu ubuntu    0 Jun 11 01:24 solution.js
-rw-r--r-- 1 ubuntu ubuntu 1931 Feb 20 02:33 server.js
-rw-r--r-- 1 ubuntu ubuntu  376 Feb 20 02:33 package.json
drwxr-xr-x 6 ubuntu ubuntu 4096 Feb 20 02:57 node_modules/
-rwxr-xr-x 1 ubuntu ubuntu   59 Jun 11 01:36 mongod*
drwxr-xr-x 2 ubuntu ubuntu 4096 Jun 11 01:35 data/
drwxr-xr-x 8 ubuntu ubuntu 4096 Feb 20 02:57 client/
-rw-r--r-- 1 ubuntu ubuntu 1001 Feb 20 02:33

audt:~/workspace $ cat mongod
mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"

Step 13 says “Whenever you run a command that includes mongod on, use ./mongod instead.”. However, when I tried to run ./monod, I got this

audt:~/workspace $ ./mongod
./mongod: line 1: mongod: command not found

I am really confused, do I need to run Step 10 to install mongoDB in my C9 workspace or not ? If not, what am I missing that mongod is not recognized ?


So, after a fair bit of mucking around and searching, I eventually figured out how to complete this MongoDB challenge. Below is summary of my experience completing the challenge to save fellow MongoDB absolute beginners on this forum some pains -

  1. The video clip (next to the instruction steps) is a bit out of sync with the instruction steps listed, notably the part that says your C9 workspace has MongoDB pre-installed. It is not true (as of posting date of this thread), so you do need to complete Step 10 Install MongoDB

  2. The video clip talks about creating a file named solution.js in your C9 workspace (not mentioned in the instruction steps) but does not explain its usage purpose (this may be obvious to people already know MongoDB, but not to someone with 0 experience). It is where you save each script (aka solution) you compose for Exercise 3 thru 9, and subsequent execute and verify by running these 2 commands in succession

learnyoumongo run solution.js
learnyoumongo verify solution.js
  1. Once you have completed Exercise 2 (connect to MongoDB), you need to open a new terminal session to do Exercise 3 thru 9. If you are not completing the whole series of exercises in one go, you will need to start the MongoDB (if not already started) and (definitely) connecting to it again next time you return to complete the exercises. See this thread

  2. Refer to MongoDB manual ( to compose your solution for Exercise 3 thru 9. This supplementary reference by Rafase282 ( is very useful for checking your solution for Exercise 3 thru 9.

Happy coding.