The course I’m doing uses Cloud 9 (C9) as cloud-based IDE. I’ve basically ignored that side of things and done everything locally on my Mac as that feels more real world to me. Turns out this was a good decision as C9 has recently announced it’s shutting down. Anyway, at times this has made things more difficult though. A good example is when I need to follow instructions to get a particular part of the development environment setup. Because all the instructions are specific to C9 it means I more or less have to figure out how to do it myself on macOS.
This morning I had an example of this exact thing when I needed to install MongoDB. I’m finally at the point that I’m starting to work with a database (hallelujah!) and I needed to get things going on my Mac. Thankfully there’s Google and I quickly found this treehouse article that gave me some clear steps to follow.
Of course it’s never quite that easy. Different machines are set up in different ways, so a guide like this doesn’t always allow for edge cases. So here’s what worked for me:
- Open terminal and use the command
brew update to update Homebrew itself to the latest version
- Now install MongoDB using
brew install mongodb. This will install the latest version
- Next we need to create a folder to house our MongoDB data files. Use the command
sudo mkdir -p /data/db. The instructions I first followed didn’t include sudo and so didn’t work for me. Your milage may vary
- We should now have a place for our data but we need to set the folder permissions using
sudo chown -R `id -un` /data/db
That’s basically it, you should now have a functional install of MongoDB. Open up two terminal windows in the first start the server with the
mongod command. In the second terminal run
mongo to launch the mongo shell for accessing data.