-
Notifications
You must be signed in to change notification settings - Fork 0
Mongo
Tim edited this page Jun 29, 2015
·
8 revisions
To set up a Mongo database:
brew install mongodbbrew install mongodnpm install mongoosenpm install body-parser- 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
- run ‘sudo mkdir -p /data/db’ >> you’ll need the sudo, this creates a folder that will host all your mongoDB databases
- 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
- 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
- run
$ mongodand 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) -
$ mongo- open mongo shell (do this in a new bash terminal)
-
> use pairs- in the mongo shell (needed first time only)
-
$ 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!