Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

If you're running Linux, here's a guide...

If you're on an Ubuntu variant for development, here's a great guide to get it installed:

https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/

There are instructions there for other distributions and package managers, as well. Simply cut and paste the commands to add the repo to your package manager and the proceed to the next steps.

Steps in CLI

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

sudo apt-get update

sudo apt-get install -y mongodb-org

Don't worry about the documented run/start of Mongo, as another way is made available below.

Alternate Run/Start Method

For an Ubuntu variant using the CLI to install, create the default directory for MongoDB in root system directory:

sudo mkdir -p /data/db

This creates the needed directory for Mong and adds it as a path to issue the mongod command soon. And then issue the following command from the CLI and substitute username with your own system username that you're using on Linux:

sudo chown -R username /data/db

This will give you (the user) permission to use that folder so that Mongo doesn't throw an error, stating that it either can't find it, write to it, or access it. Once that's done, then issue the final command:

mongod

You should see a multiple line confirmation that the Mongo service has started and the CLI window should just remain open for it to continue to listen for connections. If you're using a JetBrains product, you can also start this from the CLI within the development environment and simply leave that CLI instance open and add another if needed for routine tasks.

Michael Hulet
Michael Hulet
47,912 Points

This looks like a great guide! Which video is it supposed to go with, though?

Hi Michael,

It's supposed to go with Setting up MongoDB in the Mongo Basics course. I don't post very often... did it not attach to the right one? If not, could you help me move it over there?

Michael Hulet
Michael Hulet
47,912 Points

It looks like it didn't, unfortunately :/ In order to attach it properly, you'll need to hit the button with 3 dots next to "Add Comment", and then "Edit Question". After that, you'll need to copy the whole post, go to the video you want to attach it to, select "Get Help" under the video, give your new post a title, and then paste this one in that. This should create a new forum post with the same content as this, but attached to the video you'd like it to be attached to. After that, you can come back and delete this one, but that's up to you. Thanks for making such an awesome guide!

Thanks for helping me out with this! Very weird, right? I was in the video forum, but for some odd reason it landed here. Yes, I'll go through and try to take care of that. And thanks, I'm glad you liked it!