1. download the latest MongoDB version 2.2.2 from the official website. Click the mongodb download link, or open the terminal and enter a command such
2. After the download is complete, find the directory where the downloaded file is stored and decompress the downloaded file, for example:
After this command is executed, a folder named mongodb-osx-x86_64-2.2.2 is created under the same level directory
3. Because the installation package is stored in a temporary directory, it is best to create a new directory to store mongodb,
Sudo mkdir-p nosql/mongodb
Then, transfer the decompressed mongodb directory to the newly created directory, for example:
4. Use commands
Mkdir-p/data/db
Create the data/db directory under "/", which is the directory for storing mongoDB data.
Set/data/db Directory Permissions
Sudo chown-R your system login username/data
5. Go to the "bin" Directory of mongodb and run the "./mongod" command to start the mongoDB server. After the mongodb server is started successfully, the following message is displayed:
6. Open another terminal window, enter the "bin" directory, and run the command ". /mongo ", you can see that the mongoDB Console appears on the terminal, then you can use any MongoDB command to operate MongoDB data.
For example:
After the configuration is complete, enter the MongoDB world.