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.
-
Open your WSL terminal (ie. Ubuntu) and go to your home directory::
cd ~
-
Update your Ubuntu packages:
sudo apt update
-
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.
- Found relevant public key for
-
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.
- Used this solution to format the repo url.
- Found relevant repo for
-
Reload local package database:
sudo apt-get update
-
Install MongoDB packages:
sudo apt-get install -y mongodb-org
-
Confirm installation and get the version number:
mongod --version
-
Make a directory to store data:
mkdir -p ~/data/db
-
Run a Mongo instance:
sudo mongod --dbpath ~/data/db
-
Check to see that your MongoDB instance is running, running in a new shell:
ps -e | grep 'mongod'
-
To exit the MongoDB Shell, use the shortcut keys:
Ctrl + C