Skip to content
Tim edited this page Jun 29, 2015 · 8 revisions

To set up a Mongo database:

  1. brew install mongodb
  2. brew install mongod
  3. npm install mongoose
  4. npm install body-parser
  5. go to your home directory (cd ~) and the do cd ../../ to get to your actual root folder in your computer >> should look like a ‘/‘ in your profile
  6. run ‘sudo mkdir -p /data/db’ >> you’ll need the sudo, this creates a folder that will host all your mongoDB databases
  7. make sure you are in your root folder and directly above the new data folder and run 'sudo chmod a+w data’ this will give write access to this folder so that databases can be passed into it when you run the server
  8. do the same for the db folder within data e.g. sudo chmod a+w db >> you may not need sudo for this as should have given write access in previous step
  9. run $ mongod and you should have a server running which you will need to keep running whenever you want to access database - this command starts mongod database server (leave this running in bash terminal)
  10. $ mongo - open mongo shell (do this in a new bash terminal)
  • > use pairs - in the mongo shell (needed first time only)
  1. $ npm start - starts database (do this in another new bash terminal)
  • if it errors check nothing else is running which could contend!
  • Other things to try if it doesn't work
    • $ bower update
    • $ npm update

Other things to do in Mongo Shell: db.dropdatabase() - if you double your database!

Clone this wiki locally