Mac Install MongoDB

Source: Internet
Author: User
Tags create directory install mongodb mongodb download

Mongodb

Installation section:

Visit MongoDB Download MongoDB (2.6.0) Here we download Mac OS X 64-bit

1. The download should be tgz package such as Mongodb-osx-x86_64-2.6.0.tgz

2. Perform the decompression command on the terminal TAR-ZXVF mongodb-osx-x86_64-2.6.0.tgz

3. After decompression we can put in our own directory (optional)

4. Add the environment variable path:

Terminal input echo $PATH to view the current PATH

Add PATH command: echo "Export path=xxxxxx: $PATH" >> ~/.bash_profile

Here xxx for decompression after the path of the bin subdirectory in the MongoDB folder such as:

Echo ' Export path=/users/dalong/documents/mongodb/bin: $PATH ' >>~/.bash_profile

After setting up, open the new terminal and view path.

Run part:

1. Set the database file path

Terminal input mkdir-p/data/db Create directory

/DATA/DB is the default path be sure to ensure that the current user has read and write access to the directory.

2. Set permissions: Set permissions in the right-click Sharing and permissions on the folder (note unlock and enter the password)

Add the current user and select Read and Write permissions.

3. Terminal input Mongod running MongoDB.

If the database path is modified in the first step, the terminal input: Mongod--dbpath path (e.g. Mongod--dbpath/users/dalong/data/db/)

NODE. Js

Access http://nodejs.org/latest version of node. JS PKG Package

Direct default installation will prompt

Node is installed at "/usr/local/bin/node"
NPM is installed at "/USR/LOCAL/BIN/NPM"

Make sure That/usr/local/bin are in your $PATH.

Create example.js under/usr/local/bin/node path if unable to create please set permissions above reference

Code:

var http=Require(' HTTP '); HTTP.Createserver(function(reqRes){Res.Writehead(200{ ' content-type '  :  Text/plain ' }end ( ' Hello World \n ' } listen (1337 127.0.0.1 ' . Log ( ' Server running at http://127.0.0.1:1337/'              

Save and enter node Example.js in terminal normally displays the Server running at http://127.0.0.1:1337/

Open the browser input address http://127.0.0.1:1337/to view.

Mac Install MongoDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.