How to Install MongoDB on windows subsystem for Linux (Ubuntu Jammy)

  • Open command prompt on your windows machine (Start –> run –> cmd –>type wsl . This will put
    you in Linux bash terminal . The please execute the following commands in sequence.
  • wget -qO – https://pgp.mongodb.com/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg –dearmor
  • echo “deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
  • sudo apt update
  • sudo apt-get install -y mongodb-org
  • By default if mongodb is installed via Package manager , the data directory is /var/lib/mongodb and the log directory is /var/log/mongodb are created during the installation.
  • sudo systemctl start mongod
  • sudo systemctl status mongod
  • sudo systemctl stop mongod

Leave a Reply