How to install MongoDB 2.0 on Mac OS X (>= Leopard)
The whole install procedure is like the following.
You would have to do 7 steps.
- Download the latest tar file, and expand it.
- Move it to /usr/local/, and make a symbolic link to the folder.
- Add path to MongoDB binaries.
- Make an user that "mongod" runs on, and group that owns the user.
- Make a database directory.
- Make a log file.
- Install LaunchDaemon file.
Here are the details...
Keep it on mind that # means operating as the root, % means operating as an user.
Download the latest tar file from http://www.mongodb.org/downloads , and expand it. Then you could see a folder like this: "mongodb-osx-x86_64-2.0.0". MongoDB is really simple, so that are the all the files that are needed to start up MongoDB.
Move it to "/usr/local".
# mv mongodb-osx-x86_64-2.0.0 /usr/local/
Then make a symbolic link to the folder as the name of shorter one so that you could access the folder easily.
# ln -s /usr/local/mongodb-osx-x86_64-2.0.0 /usr/local/mongodb
Add the file that points to the binaries into "/etc/paths.d" directory, then you can access the binaries directly on your console like this: "% mongo".
# echo '/usr/local/mongodb/bin' > /etc/paths.d/mongodb
Make an account that "mongod" uses. First of all, find an UniqueID that is not currently in use, using the following command.
# dscl . list /Users UniqueID
Then, pick up one that is less than 500 not to be listed on the login window, and follow the commands below.
# dscl . -create /Users/_mongo # dscl . -create /Users/_mongo PrimaryGroupID 0 # dscl . -create /Users/_mongo UniqueID 250
You should change the UniqueID number depending on your environment.
# dscl . -append /Users/_mongo RecordName "mongo" # dscl . -create /Users/_mongo UserShell /usr/bin/false # dscl . -create /Groups/_mongo # dscl . -create /Groups/_mongo PrimaryGroupID 250
If the same PrimaryGroupID as the user is already in use, change it.
# dscl . -append /Groups/_mongo RecordName mongo # dscl . -append /Groups/_mongo GroupMembership _mongo
Let's make a database directory.
# mkdir /var/db/mongodb # chown mongo:mongo /var/db/mongodb
Then make a log file.
# touch /var/log/mongodb.log # chown mongo:mongo /var/log/mongodb.log
Download LaunchDaemon file from this gist (org.mongodb.mongod.plist). If you have correctly followed the procedure above, you don't have to correct anything in the file.
Move it to /Library/LaunchDaemons/ , and have Mac load it.
# mv org.mongodb.mongod.plist /Library/LaunchDaemons/ # launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist
That's all! Now you must be able to access MongoDB! Type "mongo" on your console!