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.