MongoDB download under the MAC installation is relatively simple, there are two main ways, one is to download the compression package decompression, the other is through the NPM or Homebrew command installation, here will not repeat,
The complex is the configuration of the MongoDB runtime environment (cannot start if the operating environment has not been configured, enter the Mongod command prompt ' is not a-a command ... ').
1, take the machine as an example, the use of compressed package to install the way:
Download the latest installation package from the MongoDB website, unzip it into the Documents/develop directory and write the name MongoDB,
2. Create a new two directory in the MongoDB directory:data/db--and storage data files, etc--for storing mongod.conf.
Use VI or another editor to create a mongod.conf file with the following content:
1 #mongodb config file 2 dbpath=/users/thomas/documents/mongodb/data/db/3 logpath=/users/thomas/documents/mongodb/ Mongod.log 4 true 5 27017 6 true 7 true
At this point the file directory structure is as follows:
3, modify the System environment variable path, add the /users/wangxi/documents/develop/mongodb/bin directory to the path.
There are many ways to modify environment variables, as follows:
First Add path:
Echo ' Export path=/users/wangxi/documents/develop/mongodb/bin: $PATH ' >>~/.bash_profile
As follows:
After adding, to make the environment variable effective, you can restart the shell terminal, or enter the command source . Bash_profile.
To see if the environment variable was added successfully:
Echo $PATH
As follows:
environment variable added successfully.
4. Start MongoDB
CMD+T Create a new command window, go to MongoDB's "bin" directory, use the command "./mongod" or "mongod" to start MongoDB server, the last line after successful startup should be the port number, as follows:
Create a new window, enter ./mongo or Mongo , and try to manipulate the database:
At this point, MongoDB has been installed and configured to complete. Yes!
Reference: http://jingyan.baidu.com/article/6fb756ecbfe474241858fb3b.html
Http://www.html5jq.com/fe/angular_node/20141218/24.html
Installing and configuring MongoDB under Mac