Giter Site home page Giter Site logo

installingmongodb's Introduction

Installing MongoDB on a MAC

A simple guide to install MongoDB on a MAC. Based on MongoDB Tutorial | Installing MongoDB On A MAC - Part 1

1. Download mongoDB

MongoDB Download Web Page

2. Extract the files from the downloaded archive

Easy way: Double-click the downloaded archive

OR

tar -zxvf mongodb-osx-x86_64-n.n.n.tgz
3. Copy the extracted archive to the target directory

Easy way: Rename the folder (mongodb) and move to the user directory (/Users/charz/)

OR

mv /Users/charz/Downloads/mongodb-osx-x86_64-n.n.n /Users/charz/mongodb
4. Create the data folder

Easy way: Create the folder structure: data/db under your user directory (/Users/charz)

OR

mkdir /Users/charz/data
mkdir /Users/charz/data/db
5. Put the binaries in the path
cd $HOME (just to make sure you are in the user directory folder - /Users/charz)
echo “export PATH=$PATH:/Users/charz/mongodb/bin” >.bash_profile

To make sure it was created correctly:

ls -la (the .bash_profile file should appear)
cat .bash_profile (the mongodb/bin folder should appear)

Exit the terminal app and reopen it

6. Create a mongod.conf file

My mongod.conf file

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /Users/charz/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /Users/charz/data/db
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

Copy my sample from the lines above or from MongoDB Github

Open TextEdit
Format - Make Plain Text
Change “logpath=” and “dbpath=”
Save to /Users/charz/mongodb/mongod.conf (to your mongodb folder installation)
7. Start mongoDB
mongod -f /Users/charz/mongodb/mongod.conf (it should not give you any error)

"mongod" to open the mongodb server

8. Test mongoDB

Open a new terminal app

mongo
use mydb
db.test.save({a:1})
db.test.find() (the object just created should appear)

"mongo" to open the mongodb client

  • New contributions and/or corrections are very WELCOME!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.