Skip to content

Instantly share code, notes, and snippets.

@leobeeson
Last active May 17, 2024 12:21
Show Gist options
  • Save leobeeson/8ac8c8ddbb0a704af26e4bd153658bde to your computer and use it in GitHub Desktop.
Save leobeeson/8ac8c8ddbb0a704af26e4bd153658bde to your computer and use it in GitHub Desktop.
Installation of MongoDB 6.0 on WSL2 Ubuntu 22.04

Installation of MongoDB 6.0 on WSL2 Ubuntu 22.04

Installed MongoDB using the following guide: Install MongoDB

However, the installation in the guide is for MongoDB 5.0 on WSL with Ubuntu 20.04 (focal) distro.

The following is an adaptation of the guide for installing MongoDB 6.0 on WSL with Ubuntu 22.04 jammy distro.

  1. Open your WSL terminal (ie. Ubuntu) and go to your home directory:: cd ~

  2. Update your Ubuntu packages: sudo apt update

  3. Import the public key used by the MongoDB package management system: wget -qO - https://pgp.mongodb.com/server-6.0.asc | sudo apt-key add -

    • Found relevant public key for MongoDB 6.0 here.
  4. Create a list file for MongoDB: echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

    • Found relevant repo for mongo server 6.0 here
    • Using the repo url as is threw the following error when running the sudo apt-get update command below:
    E: Malformed entry 1 in list file /etc/apt/sources.list.d/mongodb-org-6.0.list (Suite)
    E: The list of sources could not be read.
  5. Reload local package database: sudo apt-get update

  6. Install MongoDB packages: sudo apt-get install -y mongodb-org

  7. Confirm installation and get the version number: mongod --version

  8. Make a directory to store data: mkdir -p ~/data/db

  9. Run a Mongo instance: sudo mongod --dbpath ~/data/db

  10. Check to see that your MongoDB instance is running, running in a new shell:ps -e | grep 'mongod'

  11. To exit the MongoDB Shell, use the shortcut keys: Ctrl + C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment