Manually install MongoDB in MacOSX

Source: Internet
Author: User
Tags install mongodb
1. Download The mongodb package of The osx system from the official website to the homesoft directory and decompress it. Cdhomesoftcurl-Odownloads.mongodb.orgosxmongodb-osx-x86_64-2.6.3.tgztar-zxvfmongodb-osx-x86_64-2.6.3.tgz2, create a soft connection, and create a database directory ln-s ~ Homesoftmo

1. Download The mongodb package of The osx system from the official website to the/home/soft directory and decompress it. Cd/home/softcurl-O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.3.tgztar-zxvf mongodb-osx-x86_64-2.6.3.tgz 2. Create a soft connection and create a database directory ln-s ~ /Home/soft/mo

1. Download The mongodb package of The osx system from the official website to the/home/soft directory and decompress it.

cd /home/softcurl -O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.3.tgztar -zxvf mongodb-osx-x86_64-2.6.3.tgz

2. Create a soft connection and a database directory

ln -s ~/home/soft/mongodb-osx-x86_64-2.6.3 /usr/local/mongodbmkdir -p /usr/local/mongodb/database

3. Create a configuration file for mongodb startup and start mongodb manually.

vi /usr/local/mongodb/mongod.conf

Enter the following content and save and exit.

# MongoDB database storage directory dbpath =/usr/local/mongodb/database # log directory # logpath =/usr/local/var/log/mongodb. log # bind ip address, only allow local connection bind_ip = localhost # enable journalingjournal = true # enable RESTrest = true # enable smaller file storage # (Saving space in the development environment) smallfiles = true

Manually start mongodb and try whether it is successful:

cd /usr/local/mongodb./bin/mongod --config=./mongod.conf

Check the output. It should be OK. Control + c can be terminated.

4. Add mongodb-related commands to shell

If BASH is used, run

echo 'export PATH=/usr/local/mongodb/bin:$PATH' >> ~/.bash_profilesource ~/.bash_profile

I am using oh-my-zsh, modify ~ /. Zshrc File

vi ~/.zshrc

Add a row

export PATH=/usr/local/mongodb/bin:$PATH

Save and exit, reload

Source ~ /. Zshrc # Then you can use mongod to start mongod -- config =/usr/local/mongodb/mongod. conf.

5. Every time you manually add a long parameter and do not want to write it as cmd_start.sh, simply configure it to start automatically with the system.

vi ~/Library/LaunchAgents/org.mongodb.mongod.plist

Input

 
 
   
   
    Label
    
   
    org.mongodb.mongod
    
   
    ProgramArguments
     
   
    /usr/local/mongodb/bin/mongod
    
   
    --config=/usr/local/mongodb/mongod.conf
     
   
    RunAtLoad
    
    
   
    KeepAlive
    
   
  
 

Then register to the startup Item

launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Cancel from startup Item, use

launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Finished!

References:

Http://mac-dev-env.patrickbougie.com/mongodb/

Http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

Original article address: manually install MongoDB under Mac OSX. Thank you for sharing it with me.

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.