Mac under Install Start MongoDB

Source: Internet
Author: User
Tags brew install mongodb install mongodb

I recently started the Mac, in the use of Mac has a lot of unfamiliar places, slowly groping, recorded, for follow-up and reference:

To install MongoDB mode under Mac

First, with browser or third-party tools to download
Current version of:http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.6.tgz

The second, through the homebrew installation mongodb,terminal run the following instructions can be

Here, I only speak through homebrew to install.

Install MongoDB under Mac, via homebrew

1. Installing MongoDB via Homebrew

    $ brew Update     $ brew Install MongoDB

If you don't have a homebrew, you should put one first, and the programmer must.

2. MongoDB data default exists/data/db, so need to create this folder, and set permissions

Take the first step, where we can perform the installation

sudo mongod

After executing the sudo mongod command, a bunch of error messages are returned, as follows:

So a bunch of wrong messages, the point is these words

Error:dbpath (/data/db) does not exist. Create this directory or give existing directory In–dbpath. See Http://dochub.mongodb.org/core/startingandstoppingmongo

The error message means dbpath (/data/db) No, you need to create /data/db this directory or use --dbpath a parameter entry to specify a directory that already exists.

DBPath (/data/db) This directory is the place to store MongoDB data files

Since it doesn't exist /data/db , let's create this directory.

First return to the disk root in the terminal input cd / command

then enter the command

Mkdir-p/data/db    Create/data/db

Re-enter the sudo mongod command to start the MongoDB service, and the service exits again to return a bunch of information as follows:

The reason for the error is that these sentences log

Create/open lock file:/data/db/mongod.lock errno:13 Permission denied is a mongod     instance already running?, Terminat Ing

Meaning is not to create and open /data/db/mongod.lock this file, because Permission denied (Permission denied), it appears that the current user mongod to execute this command, the /data/db directory does not have permission to operate, OK, know the reason is good to do, to /data/db add permissions.

Enter the following command at the terminal:

sudo chown-r  The user name that is currently logged on/data

If you are not sure you can run $ whoami first

Again in the terminal input sudo mongod start MongoDB service

3. Add Mongodb/bin to $path, lest we enter sudo monogd each time and become direct MONOGD

    $ touch. Base_profile    $ vim. Base_profile

Restart terminal after adding the following address

Export Mongo_path=/usr/local/mongodb  export path= $PATH: $MONGO _path/bin  

4. Start MongoDB

$ mongod

5. Query Database

Run in another terminal window

$ mongod

You can then start various database directives, such as

    $show DBS    Displays databases that already exist    $use somedbname    Create (use) a database

6. Exit

$exit

Mac under Install Start 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.