I next plan to cover an example of using mLab to host a free MongoDB database which we will look at using PyMongo.
To close MongoDB, hold control + c in the active terminal shell. This runs MongoDB locally on your machine (by default at port 27017).Ħ. You should still be in the "bin" directory. Stay in the shell, but log out as the root user by running exit. Change the permissions on the "data" and "data/db" directories so that everyone may read from, write to them. The "-p" flag stands for "path" and creates nested directories if they do not exist already (like the os.makedirs function in Python).Ĥ. Note this is an unofficial & unsupported mongo.so build, the same as what you should get building successfully from source with pecl install mongo.
Become the root user by running sudo bash and entering your password when prompted. Essentially, I just pasted the example from the MongoDB PHP Driver Tutorial, and inserted some documents into MongoDB 2.0.6 running on another computer. data/db, but you first have to create this directory.
It is available for download from the MongoDB website. "mongo" lets you run the MongoDB shell (called "mongo"). MongoDB Community Server can be installed on Windows, Mac, Solaris, and various Linux distributions.Note: The two most important files in this directory are "mongo" and "mongod" ("mawn-go-dee"). Change directories to the newly created folder "mongodb-osx-x86_64-3.6.0" by running cd mongodb-osx-x86_64-3.6.0. Note that this tutorial is not eternally valid and the version number (currently 3.6.0) will need to be replaced by whatever version number you downloaded. Go to your terminal shell, change directories to wherever the downloaded file is, and unpack the downloaded file by running tar xvf mongodb-osx-x86_64-3.6.0.tgz.
If you already have added the above steps then MongoDB will start by the time your MAC OS started.1. Save the file and load the above job: $ sudo launchctl load /Library /LaunchDaemons /istĠ 12 1 0 4:06PM ? 0: 20.29 /usr /local /mongodb /bin /mongodĥ01 542 435 0 4:37PM ttys000 0: 00.00 grep mongo
$ sudo vim /Library /LaunchDaemons /istĪnd add the following content to “ /Library/LaunchDaemons/ist” Label mongodb ProgramArguments /usr /local /mongodb /bin /mongod RunAtLoad KeepAlive WorkingDirectory /usr /local /mongodb StandardErrorPath /var /log /mongodb /error.log StandardOutPath /var /log /mongodb /output.log To auto start yor installed mongoDB, create a launchd job on your Mac OS. $ cd ~Įxport MONGO_PATH = / usr / local / mongodb Step 4: Set you PATH on Bash Profile for MongoDB:Ĭreate a ~/.bash_profile file if not exists else update, and assign /usr/local/mongodb/bin to $PATH environment variable, so that you can access MongoDB on commands easily. $ sudo mv mongodb-osx-x86_64-2.6.1 /usr /local /mongodbīy default, MongoDB write/store data into the /data/db folder, you need to create this folder manually and assign proper permission as given below: $ sudo mkdir -p /data /db Step 2: Install MongoDB: $ cd ~ /Download
Easy spets to nstall MongoDB on Mac OS X ( I have used MAC OS – Mavericks)ĭownload MongoDB for MAC OS from official MongoDB site: