Understanding of how to download mongodb Community Edition from https://www.mongodb.com/try/download/community.
- When you download a .tgz file from https://www.mongodb.com/try/download/community, as shown in IMAGE_1.
-
After downloading, move the .tgz folder to your home directory using this command in your terminal:
mv mongodb-macos-x86_64-7.0.11 /Users/smitimac27
(Info : mv (move)
mongodb-macos-x86_64-7.0.11 (MongoDB file name)
/Users/smitimac27 (your Home directory replace this with your own username))
Refer to IMAGE_2.
-
Redirect to the home folder by typing cd.
-
Type ls -all to confirm that your MongoDB folder is present.
See IMAGE_3.
-
Navigate inside the MongoDB folder by typing:
cd mongodb-macos-x86_64-7.0.11
-
Type ls to view all folders inside your MongoDB directory.
-
Go to the bin folder using:
cd bin
Use ls to view the binaries mongod and mongos.
Refer to IMAGE_4.
-
Copy the bin path into the .zshrc file to ensure mongod is recognized.
-
First, check if your .zshrc file exists by typing:
cd
ls -all
If .zshrc is not present, create it with:
touch .zshrc
If it already exists, open it with
open .zshrc
See IMAGE_5.
-
Add the following line to your .zshrc file:
export PATH=$PATH:/Users/smitimac27/mongodb-macos-x86_64-7.0.11/bin
Refer to IMAGE_6
For instructions on copying the bin path, navigate to /Users -> your username -> find MongoDB -> bin. Click on view and select show path bar. Right-click on the bin folder to copy ‘bin’ as pathname. Refer to IMAGE_7.
-
After editing .zshrc, return to the terminal and execute:
source .zshrc
-
Type
mongod
to start MongoDB. -
If there’s an error due to the absence of a data directory, resolve it by creating it:
sudo mkdir -p /data/db
-
If there’s an error due to the absence of a data directory, resolve it by creating it
ls cd data ls
-
Start mongod with the following command, specifying the data directory:
sudo mongod --dbpath=/Users/yourUsername/data/db
Enter your password as required.