MongoDB provides a 64-bit installation package for OSX, which you can download from the official website.
Download: www.mongodb.com/download-ce…
Curl = curl = curl = curl
# enter CD/usr/local/usr/local # download sudo curl - O https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-4.0.9.tgz # extract Tar -zxvf mongodb-osx-ssl-x86_64-4.0.9. TGZ # rename mongodb to sudo mv mongodb-osx-x86_64-4.0.9/ mongodbCopy the code
After installation, we can add the MongoDB binary command file directory (installation directory /bin) to the PATH PATH:
export PATH=/usr/local/mongodb/bin:$PATH
Copy the code
Create directory for storing logs and data:
- Data storage path:
sudo mkdir -p /usr/local/var/mongodb
Copy the code
Log file path:
sudo mkdir -p /usr/local/var/log/mongodb
Copy the code
Next, make sure that the current user has read and write permission to the above two directories:
sudo chown zy /usr/local/var/mongodb
sudo chown zy /usr/local/var/log/mongodb
Copy the code
The above ZY is for the user on my computer, you need to modify it according to your current user name.
Next we start mongodb in the background with the following command :(turn off terminal and try several times)
sudo mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork
Copy the code
- Dbpath Sets the directory for storing data
- Logpath Sets the directory for storing logs
- Fork runs in the background
Install MongoDB on Apple computer for a long time has been installed well, later friends share the link reference link, so I copied it down, if there is infringement, please contact to delete the original link