Last active
November 9, 2017 18:35
-
-
Save chetstone/7bb4654668f80a7c414ad30f42b1084f to your computer and use it in GitHub Desktop.
Installing mongoldb on mac with homebrew
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install MongoDB on Mac OS X Yosemite | |
by César Trigo · November 6, 2014 | |
from mongodbspain: http://web.archive.org/web/20141121161054/http://www.mongodbspain.com/en/2014/11/06/install-mongodb-on-mac-os-x-yosemite/ | |
OS X Yosemite | |
Install MongoDB in our Mac is something simple and easy. There are two ways to install MongoDB under Mac OS X: | |
Manually, through the official binaries | |
Through Homebrew, the famous package manager for Mac OS | |
In this article we will approach the installation through the second option, Homebrew, mainly because this is the most easy and fast method to start working with MongoDB in our Mac | |
Installation | |
Step 1: Intall Homebrew package manager: | |
1 | |
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
Paso: 2: Update the Hombrew packages database | |
1 | |
$ brew update | |
Step 3: Install MongoDB | |
With this command you will install MongoDB from the binaries: | |
1 | |
$ brew install mongodb | |
… but there are other available installation options. The most important are: | |
1 | |
2 | |
3 | |
4 | |
5 | |
//Install with Open SSL support | |
$ brew install mongodb --with-openssl | |
//Install from the last available development release (not recommended for Production Environments) | |
$ brew install mongodb --devel | |
Check the MongoDB installation | |
Now you have MongoDB installed in your system, but before start working, lets see what has happened: | |
MongoDB has been installed in the directory: /usr/local/Cellar/mongodb/2.6.5 | |
A new configuration file mongod.conf has been created automatically. This file should store the MongoDB run-time configuration and is available here: /usr/local/etc/mongod.conf. Lets take a look to this file: | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
$ cat mongod.conf | |
systemLog: | |
destination: file | |
path: /usr/local/var/log/mongodb/mongo.log | |
logAppend: true | |
storage: | |
dbPath: /usr/local/var/mongodb | |
net: | |
bindIp: 127.0.0.1 | |
Now you’ll see where the logs will be stored in the file /usr/local/var/log/mongodb/mongo.log and the data path /usr/local/var/mongodb | |
Run MongoDB | |
To execute MongoDB you can use the next command from the terminal: | |
1 | |
$ mongod --config /usr/local/etc/mongod.conf | |
Or launch MongoDB in background followed by the command –fork | |
1 | |
$ mongod --config /usr/local/etc/mongod.conf --fork | |
However, if you want to keep MongoDB running at any time, even when you reboot the system, you should use the following commands: | |
1 | |
2 | |
3 | |
4 | |
5 | |
//Start mongod main process on session start: | |
$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents | |
//Start MongoDB now, in background, and keep it running | |
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist | |
In addition, you will be able to use the following modifiers to change the default configurations: | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
//Select manually the data directory | |
$ mongod --dbpath <path to data directory> | |
//Select manually the log file | |
$ mongod --logpath <path to .log config file> | |
//Select manually the configguration file | |
$ mongod --config <path to .conf config file> | |
Start using MongoDB | |
From now, MongoDB is available in your system and you can start MongoDB Shell from anywhere. You just have to open a terminal and use the mongo command to start: | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
$ mongo | |
MongoDB shell version: 2.6.5 | |
connecting to: test | |
Welcome to the MongoDB shell. | |
For interactive help, type "help". | |
For more comprehensive documentation, see | |
http://docs.mongodb.org/ | |
Questions? Try the support group | |
http://groups.google.com/group/mongodb-user | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment